I’ve an Document object and User object, generated by Entity Framework Model Generator.
I want to get Document list, plus userCount created according to this Document.
So, I’ve created new object DocumentWithUserCount:
public class DocumentWithUserCount:Document
{
public uAmount {get;set}
}
And LINQ to retain data (below code, I need your help) :
var ed = (from d in _entity.Document
join p in _entity.User[get DocID and count by this docID ] on d.RID equals p.DocID
select new DocumentWithUserCount(xxxx)).ToList();
How to do this?
EDIT:
Simply I want to do equivalent code below with LINQ.
SELECT d.*, p.* from Document d INNER JOIN (select docid, count(RID) as uAmount from User
GROUP BY DocID) p ON d.RID=p.docid
I think that inheritance is the wrong tool here. Use composition instead. And It’s not clear if you even nneed the Join, there should be a navigation property:
or