English 中文(简体)
提高效率 Linq-to-SQL query
原标题:More efficient Linq-to-SQL query

我期待着采取更有效的办法......(见下文)。 我必须做七次,因为我有七个专题文章。 我正在开脱的那页(aka的特写文章,fk_pageID_item1的特稿,fk_pageID_item2)。

我正在做一个表格,而不是选择这个表格。 我也正在制造一个暂时搁置信息的物体。

DataAccess.Page pgf1 = (from p in db.Pages
where p.pageID == featurearticles.fk_pageID_item1
select p).FirstOrDefault();

PageArticle paf1 =(from pa in db.PageArticles
where pa.page_art_pageID == pgf1.pageID &&
pa.page_art_isCurrent ==true
select pa).FirstOrDefault();

Article af1 = (from a in db.Articles
where a.articleID == paf1.page_art_articleID
select a).FirstOrDefault();
  1. gets a page.
  2. gets the current version.
  3. gets the info for that version.

我坐在桌旁。

感谢。

最佳回答

这笔贷款大部分是给住者。

Article af1 = (from p in db.Pages
               join pa in db.PageArticles on p.pageID equals pa.page_art_pageID
               join a in db.Articles on pa.page_art_articleID equals a.articleID
               where p.pageID == featurearticles.fk_pageID_item1
               && pa.page_art_isCurrent == true
               select a).FirstOrDefault();

你们应该能够利用这一问询来替代你们已经拥有的东西。

问题回答

了解这一点。 所有这些都是内在的,我不清楚这是否完全是你所需要的? 否则,让我知道。

var tp = from p in Pages
    join pa in PageArticles on p.pageID equals pa.page_art_pageID
    join a in Articles on pa.page_art_articleID equals a.articleID
    where p.pageID == featurearticles.fk_pageID_item1
    && pa.page_art_isCurrent
    select new { p, pa, a };

我也可以把新选择改变到你要求的领域。





相关问题
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!

热门标签