2011-11-28 17 views
-3
Global entity: { WorkerId , ProjId, Date } 
Worker entity: { Workerid, WorkerName } 
Project entity: { ProjId, ProjName } 
New Projects entity : { ProjId, ProjInf } 

的的WebMethod需要收到的日期,并返回:LINQ专业查询的WebMethod

>WorkerName 
>how many projects he has // count Project entity with WorkerId 
>how many new projects he has // count New Projects entity with ProjId, we know wich ProjId needs to be count for the worker from the Global entity 

请帮我建立这个LINQ查询......我不能发现所有对谷歌的任何解决方案

+0

请张贴在未来的更多信息。正确解释您的实体的实体关系以及您尝试使用的相同代码(http://stackoverflow.com/questions/how-to-ask) – DaveShaw

回答

1

这是不知道更多关于你的实体模型,我可以在想最好的:

var results = 
    objectContext.Global 
    .Where(g => g.Date == dateTimeParam) 
    .Select(
    g => 
     new 
     { 
     WorkerName = g.Worker.Name, 
     ProjectCount = g.Worker.Projects.Count(), 
     NewProjectCount = g.Worker.NewProjects.Count(), 
     }); 
+0

谢谢,请参阅我根据您的代码编写的内容 – Sveta23

+0

I会根据您遇到的错误开启一个新问题,现在您已经有了一个代码示例和一个特定的问题。 – DaveShaw