In a C#.asp.net 2010 web form application that connects to a sql server 2008 r2 database, I would like to write a linq to sql
statement that will translate to:
Select field1 from testtable
where column1='customer' and column2 = 'statename'.
The sql would run using an existing datacontext object.
Can you should me some code that would accomplish this task?
Loading
VulpesPosted Jun 7, 2012, 6:10 PM
http://www.hookedonlinq.com/LINQToSQLFAQ.ashx
However, if you're directly executing the query using the ExecuteQuery method, then you need to follow the procedure in this MSDN link to allow for parameters:
http://msdn.microsoft.com/en-us/library/bb399403.aspx
VulpesPosted Jun 8, 2012, 9:48 AM
There's no need to allow for this specifically in the query though you may, of course, need to deal with it in subsequent processing.
Nattudurai EswaramurthyPosted Jun 8, 2012, 12:29 AM
var result = from s in context.tablename
where s.column1 == param1 && s.column2 ==param2
select s.columnname;
Hope this will help u
scampercatPosted Jun 7, 2012, 3:07 PM
VulpesPosted Jun 7, 2012, 2:05 PM