I’m new to LINQ, and (sadly) i need to convert some messed sql command to Linq.
There are two simple tables in my database. First one is holding names (cols “Name” and “NameID”), other table holds nicknames (cols “Nick”, “NickID”, “FK_NameID”). Each nickname has ID and foreign key pointing to real name (name ID).
Using C#, this code was used to retrive any nickname that contains “SomeString” in it:
comm = new SqlCommand("SELECT Name FROM Names INNER JOIN Nicks ON NameID = FK_NameID AND Nick LIKE '%" + SomeString + "%'", Connection);
As far as i saw after googling, “Like” and “Join” in SQL command could produce complicated Linq :\ Can you help me out and tell me what LINQ expression would be equal to that SQL command i was using so far? Is there any was to bypass Linq and use DataSet, DataTables instead?
I’m total Linq-noob :\
It’s pretty similar actually:
You should think about your column names –
FK_NameIdwould be better asNameId(in my opinion).