Home

Newby requires guidance.

Hi all, I hope this is a good place to ask this question and hope that if it isn't that I wont have offended anyone.

I have mastered (well probably not mastered but am adept at) simple LINQ queries to a Sqlserver database but I have a task that requires the translation of some sql into a viable Linq statement. I have tried so many things for literally hours and scoured the internet to find a solution but I haven't found what I'm looking for yet. I may well be terminally stoopid, but I hope not.

So here goes, this is my sql which works very nicely but needs to be converted to Linq,

SELECTt a.ID FROM activity_activity a
JOIN activityWellboreLink aw ON aw.ActivityID = a.ID AND aw.WellboreID = 5235
JOIN core_timerange c ON c.Id = a.timeRangeID
AND c.StarttimeStamp >= 1392159600000
AND c.EndTimeStamp <= 1392159686400

If anyone could give some pointers I would be so very grateful.
Regards,
Martin.

Comments

  • Have you worked through the built-in tutorial in LINQPad?

    Go to the samples tab in the bottom left and click 'C# 5 in a Nutshell'. This will give you the background on LINQ and explain how to perform joins.

    Bear in mind that association properties make this much easier in LINQ. You shouldn't in most cases need to join at all to accomplish this kind of query.

Sign In or Register to comment.