i need to write sql query in string and pass it to linq like executenonquery() in ado.net
but i need to return data from 4 tables
Example Query :
SELECT *
FROM dbo.GeneralAd INNER JOIN
dbo.Category ON dbo.GeneralAd.FkCategoryID = dbo.Category.CategoryID INNER JOIN
dbo.District ON dbo.GeneralAd.FkDistrictID = dbo.District.DistrictID LEFT OUTER JOIN
dbo.Users ON dbo.GeneralAd.FkApprovedByID = dbo.Users.UserID AND dbo.GeneralAd.FKAddedByID = dbo.Users.UserID where .........
how to return data from 4 tables with executenonquery method in linq ?
I’m not sure why you why you want to return all columns from all tables. That seems unnecessary. You can get to the District and Category fields from the GeneralAd object.
What I would probably do is define a property on the General Ad object that executes a select to get the associated User.
If you did want to do it in Linq, you could use something like this:
You might have to add an Any() method on Col4: