LINQ - linq to sql - Asked By suha on 02-Apr-11 09:34 AM

hi,
can i call a stored procedure in linq to sql without using  linq sql classes item in asp.net 3.5?
I mean without the designer in a mutil  tier application like ADO.NET.if not?
what is the benefit of this technique? is n't it breaking the encapsulation of data. Does the linq to Entity solve the problem.

thanks in advance   
Jitendra Faye replied to suha on 05-Apr-11 05:38 AM
Yes using LinqToSQL you can call Stored procedure in your Application, In this case Stored Procedure
will be in the form of method of DataContext,-

for calling stored procedure you have to use following syntax-

var dbNorthwind =new NorthwindDataContext() ;
var query = dbNorthwind.SalesByCategory("Beverages","1997");    

Plz follow the below link for more details-

http://www.mssqltips.com/tip.asp?tip=1542
and
http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx

I hope this both links will help you.

Jatin Trikha replied to suha on 05-Apr-11 07:52 AM
No its not possible to do it without linq class library you need to take them in you code. i.e. you need to have a dbml i you project, or create class with "Table" & "Column" attribute.

Linq is not dependent as to whether you application is multiple tier or not. The basic advantage of Linq is that now developer can access and use the SQL in coding language instead of asking of DB teams. For more benefits you can visit www.msdn.com

Also the biggest benefits of entity to sql over Linq to SQL that its is not MS sql server dependent where linq is possible only in SQL server.


For syntax's you can refer the above reply.