English 中文(简体)
哪些准则表明,我不需要这样做,没有漏洞?
原标题:Which LINQ expression do I need for this, without looping?


I have an MSSQL database with LINQ to SQL.
I have three tables.
Requests -> id, string name
Results -> id, requestID, int jumps
Places -> id, resultID, int location

Then, using an input string, I need to get an ICollectable or array or something of Place which meets the following:
Each Request that has name=input, take its ID.[you can assume only one has]
Each Result that has requestID=ID[from above] - take its id.
Each Place that has resultID= id[from above] - append to array for further processing.

我通过在所有<代码>Results上登出,然后执行另一个<代码>LINQ说明,但该说明的极端缓慢[仅请求约500万立方米!]。 ∗∗∗∗

谢谢!

Edit:名人,我也需要按结果分类。 aka a 职位清单,而每个内部名单则包含一个栏目:<代码>Result。

最佳回答

您可在林克2Sql通过加入关键词来做桌子:

var places = from request in Requests 
             join result in Results on request.Id equals result.requestID
             join place in Places on result.Id equals place.ResultId
             where request.name = input
             select place;
问题回答

类似

Requests.Where(r => r.name == input).Results.Places.Select();

如果这种速度太慢,我就期望你们需要一些指数。

如果你在模式上没有关系,那么你就必须在表格上确定一些外国关键制约因素,以重建你的模式。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签