开发者

Linq to Entities over WCF query help

Im using WCF data services to get my data from a Silverlight application, and I have a query of which I dont know how to write.

I have 2 tables, Resources and UnavailableResources they join on Resource.id and UnavailableResources.resource_id

the UnavailableResources table holds a record of a day that a resource is not available, so it is assumed that if there is no record in the table for a given date, the resource is available.

开发者_如何学Go

I would like to do a query for a date range (i.e. a given week) where for each day, I get all resources (if they are available or not), and, if they are unavailable, then get the status code (inside the UnavailableResources table which joins to a status table)

How can I do this?


From what I understood from your question:

var svcContext = new ServiceContext(svcURI);

var LeftJoin = from res in svcContext.Resources
join un_res in svcContext.UnavaialableResources
on res.id equals un_res.resource_id into joinedResources 
from res in joinedResources.DefaultIfEmpty()
select new                          
{
// Properties you need

Status = GetStatus(isAvailable,res.id)                          
};

You can do more joins on the LeftJoin query to get what you want. Let me know if I got your question right.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜