Prev: Scrolling Large Text File Without Hogging Memory
Next: Need "Jump Start" example of Using ForumService
From: Mr. Arnold on 26 May 2010 16:47 Rich P wrote: > I added a reference to System.Data.Linq > > and a > > using System.Data.Linq.SqlClient; > > and attempted the following query: > > var query1 = from DataRow myRow in ds1.Tables["tblA"].Rows > where SqlMethods.Like(myRow["Company"], "%test%") > select myRow; > > > In the error message that ensued -- it mentioned that SqlMethods > currently only works with Linq To Sql. I guess this is Linq to a > Datatable. The rest of the error said that I had some invalid argument It's going to be this I believe. myRow.Contains("something")
From: Arne Vajhøj on 26 May 2010 22:08 On 26-05-2010 15:26, Rich P wrote: > Thanks. I will give that a try. Although, in my searching, other > articles suggested that Contains does not handle wildcards. I guess I > will find out. LIKE '%foobar%' is .Contains("foobar"), but for more advanced usages of LIKE you will need to do something like a selecting where a lambda using regex returns true. Arne
From: Rich P on 27 May 2010 11:33 I attempted something like this: list = list.Where(o => SqlMethods.Like(o.FirstName, FirstName)) but the error message said that SqlMethods.Like only works with Linq to Sql. I am trying to use Linq on a dataTable in my C# (2008) winform app. Any thoughts appreciated if there is a workaround for using SqlMethods against a dataTable contained in the app. Rich *** Sent via Developersdex http://www.developersdex.com ***
From: Patrice on 27 May 2010 14:30 Keep in mind that Linq is not SQL but just C#. So Contains be translated to %Value%, StartsWith to Value% and EndsWith to %Value. If you need more specific patterns server side, you'll have to create your own function mapping. http://msdn.microsoft.com/en-us/library/dd456828(v=VS.100).aspx should help. -- Patrice "Rich P" <rpng123(a)aol.com> a �crit dans le message de groupe de discussion : Ol5wYlQ$KHA.5280(a)TK2MSFTNGP05.phx.gbl... > Thanks. I will give that a try. Although, in my searching, other > articles suggested that Contains does not handle wildcards. I guess I > will find out. > > Thanks again for the reply and suggestion. > > Rich > > *** Sent via Developersdex http://www.developersdex.com *** >
From: Mr. Arnold on 27 May 2010 18:55 Rich P wrote: > I attempted something like this: > > list = list.Where(o => SqlMethods.Like(o.FirstName, FirstName)) > > > but the error message said that SqlMethods.Like only works with Linq to > Sql. I am trying to use Linq on a dataTable in my C# (2008) winform > app. Any thoughts appreciated if there is a workaround for using > SqlMethods against a dataTable contained in the app. > You can't use the statement as it only pertains to querying a SQL Server table on the entity model using Linq. http://msdn.microsoft.com/en-us/library/system.data.linq.sqlclient.sqlmethods.like.aspx
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Scrolling Large Text File Without Hogging Memory Next: Need "Jump Start" example of Using ForumService |