Archive for the 'Uncategorized' Category
1) We can use XSD Tool ( Xml Schema Definition Tool ) or XSD.exe to generate class files (.cs or .vb ) as per your requirments from Typed Datasets. XSD.exe is the XML Schema Definition tool which generates XML schema or common language runtime classes from XDR, XML, and XSD files.
The file locates at C:\Program [...]
September 24th, 2009 | Posted in Uncategorized | No Comments
Problem:
When you change the structure of your sql tables — say, change a type from a varchar to… say an int — the linq to sql class model (eg. project.dbml) is not updated or sync’d.
Is there a way to sync the model with the db?
Solution:
1) One way is to delete the ‘table’ in the class [...]
September 24th, 2009 | Posted in Uncategorized | No Comments
The SqlMetal command-line tool generates code and mapping for the LINQ to SQL component of the .NET Framework. By applying options that appear later in this topic, you can instruct SqlMetal to perform several different actions that include the following:
* From a database, generate source code and mapping attributes or a mapping file.
* [...]
September 24th, 2009 | Posted in Uncategorized | No Comments
To update a row in the database
Query the database for the row to be updated.
Make desired changes to member values in the resulting LINQ to SQL object.
Submit the changes to the database.
// Query the database for the row to be updated.
var query =
from ord in db.Orders
where ord.OrderID [...]
September 24th, 2009 | Posted in Uncategorized | No Comments
To insert a row into the database
Create a new object that includes the column data to be submitted.
Add the new object to the LINQ to SQL Table collection associated with the target table in the database.
Submit the change to the database.
What earlier was adding rows to tables, now is just adding new objects to context collections. [...]
September 24th, 2009 | Posted in Uncategorized | No Comments
LINQ to SQL: .NET Language-Integrated Query for Relational Data” says (last item in the “Column Attribute” section): “Specifies if the column is automatically synchronized from the value generated by the database on insert or update commands.
public enum AutoSync {
Default = 0, // Automatically choose
Always = 1,
Never = 2,
OnInsert = 3,
OnUpdate = 4
}
September 24th, 2009 | Posted in Uncategorized | No Comments
Now that we have generated our data layer. We will work on ASP.NET web application where we will use our data layer. To keep things simple we will create a web forms to search for customers and display search results. We will also create a web form to insert new customers. Let’s start by creating [...]
September 10th, 2009 | Posted in Uncategorized | No Comments
1) Before we generate our data layer we must create a new connection in Server Explorer which points to Northwind database.
2) We will now generate our data layer using LINQ To SQL. To do this you need to add a new item to the data layer project of type LINQ to SQL Classes. We will [...]
September 10th, 2009 | Posted in Uncategorized | No Comments
Traditionally, working with collections of objects meant writing a lot of looping code using for loops or foreach loops to iterate through a list carrying out filtering using if statements, and some action like keeping a running sum of a total property. LINQ frees you from having to write looping code; it allows you to [...]
September 10th, 2009 | Posted in Uncategorized | No Comments
Language Integrated Query (or LINQ, pronounced “link” for short), is a set of Microsoft® .NET technologies that provide built-in language querying functionality similar to SQL, not only for database access, but for accessing data from any source.
There is no one definition for LINQ, but it aims to solve the problem where we currently use different [...]
September 10th, 2009 | Posted in Uncategorized | No Comments