C#
C# Entity Framework join 하기
saltdoll
2018. 1. 11. 06:26
반응형
Entity Framework 에서 Join하기
join 테이블명 on 필드A equals 필드B
select 에서 new { }로 각 필드를 새롭게 만들어 준다.
I think it will be easier using syntax-based query:
var entryPoint = (from ep in dbContext.tbl_EntryPoint
join e in dbContext.tbl_Entry on ep.EID equals e.EID
join t in dbContext.tbl_Title on e.TID equals t.TID
where e.OwnerID == user.UID
select new {
UID = e.OwnerID,
TID = e.TID,
Title = t.Title,
EID = e.EID
}).Take(10);
And you should probably add orderby
clause, to make sure Top(10)
returns correct top ten items.
출처: https://stackoverflow.com/questions/21051612/entity-framework-join-3-tables
반응형