Q. What is LINQ?
LINQ is a set of language features introduced in .NET 3.5 (shipping Visual Studio 2008) that allow you to write queries similar to SQL like statements in Visual Basic or C# programs (other language support is available, but these are the main ones). LINQ knows the data-source you are trying to query (SQL Server, object collection, or another source) and executes the query expression returning the result in the form you ask.Edit
Q. What is LINQ to SQL?
LINQ to SQL is a specific LINQ implementation for SQL Server. LINQ to SQL converts LINQ queries written in C# or Visual Basic into dynamic SQL, execute it on the server and marshal the results in return. LINQ to SQL also supports making changes to the returned objects and applying those updates back to the database. These updates can be applied by the LINQ framework using dynamic SQL or Stored Procedures. See: LINQ to SQL main page
, and LINQ to SQL 5 minute overview
Q. How do I enable LINQ to SQL in my code?
To use LINQ to SQL in Visual Studio 2008 -
1) add a reference to the
(if it is grayed out, go to your project properties and set the target framework to .NET 3.5)
2) add the following using statement at the top of your class file:
using System.Data.Linq; Edit
Q. What versions of C# Supports LINQ?
C#3.0 that ships in the .NET 3.5 framework as part of Visual Studio 2008 supports LINQ. It was possible to run a LINQ preview in Visual Studio 2005 mid 2006, but as the beta releases of Visual Studio 2008 became available this support was dropped.Edit
Q. Do I need to know LINQ syntax to program?
No. Developing using LINQ is completely optional. LINQ does remove a lot of the traditional ADO.NET complexity.Edit
Q. What .NET languages currently support LINQ?
Currently C# and Visual Basic shipping with the .NET Framework 3.5 (in Visual Studio 2008) have specific language features and debugger support for LINQ. Edit
Q. Am I exposed to SQL Injection attacks?
No. LINQ to SQL passes all data to the database via SQL parameters. So, although the SQL query is composed dynamically, the values are substitued server side through parameters safeguarding against the most common cause of SQL injection attacks. Security is a big topic though, so stay diligant!Edit
Q. Does LINQ to SQL support Stored Procedures?
Yes. LINQ to SQL supports calling Stored Procedures by directly wrapping them in strongly typed C# or VB method signatures. It also supports you specifying a specific Insert, Update and Delete stored procedures to make the appropriate changes to the database based on onject updates made in C# and VB.Edit
Q. How can I support Optional Parameters when calling a Stored Procedure through LINQ to SQL?
See this article on the subject: Stored Procedure Optional Parameters using LINQ to SQLEdit
Q. Can LINQ to SQL perform batch updates and deletes? Or does it always do one row update at a time?
By default, LINQ to SQL will perform a single row update when datacontext.SubmitChanges() is called after many rows have been deleted, or modified.Terry Aney
has posted his solution in the form of a few very cool extension methods that support batch deletes and updates. See the article here.
Q. How can I improve LINQ to SQL Performance?Sidar Ok
has a great blog posting 10 Tips to Improve your LINQ to SQL Application Performance
which covers some great tips.
Century 21 Broker Properti Jual Beli Sewa Rumah Indonesia