TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chinni Rupa
NA
7
469
Trying to Convert SQL to LINQ
Nov 8 2019 4:59 PM
I am tryign to convert to LINQ
WITH test AS (
SELECT DISTINCT
SiteID
FROM dbo.RepresentativeItemMeasurementDailySummary)
SELECT
S.SiteCode
FROM dbo.Sites S
INNER JOIN test X ON X.SiteID = S.SiteID
INNER JOIN dbo.SiteExtends SE ON SE.SiteID = S.SiteID
WHERE SE.StartTime > '0:00'
This is what I have tried
var sites = (from s in context.RepresentativeItemMeasurementDailySummary
join se in context.Sites on s.SiteID equals se.SiteID
where se.SiteCode == SiteCode
select new { s.SiteID, se.SiteCode }).Distinct();
var workingTimes = (from s in context.Sites
join se in context.SiteExtends on s.SiteID equals se.SiteID
where se.StartTime > TimeSpan.Zero
&& s.SiteCode == SiteCode
select new { se.SiteID, s.SiteCode }).ToList();
var comb = (from t in sites
from t1 in workingTimes
where (t.SiteID == t1.SiteID && t.SiteCode == t1.SiteCode)
select new Sites { SiteID = t.SiteID,SiteCode = t.SiteCode }).ToList();
return comb.Distinct().ToList();
Can someone help me with this
Thanks!!
Reply
Answers (
2
)
What are the ways we can load related entities in Entity...
Why we use generic repository pattern