English 中文(简体)
Linq, 效仿结合, 包括方法
原标题:Linq, emulating joins, and the Include method

I m looking into an issue that is related to... Join and Include in Entity Framework

基本上,下面的询问将“财产”清单退回到目前用户已允许查阅(ACLs)。

IQueryable<Property> currPropList 
                = from p in ve.Property
                                .Include("phyAddress")
                                .Include("Contact")
                  from a in ve.ACLs
                  from u in ve.Account
                  from gj in ve.ObjectGroupJoin
                  where u.username == currUsername              // The username
                        && (a.Account.id == u.id                // The ACLs
                            && a.objType == (int)ObjectType.Group)
                        && (gj.ObjectGroup.id == a.objId        // The groups
                            && gj.objId == p.id)                // The properties
                  select p;

质询归还了正确的财产清单和大宗工程罚款。

但是,上述林盖中的“Include”电话并不装载物体。 如果在LINQ问询之后我明确叫“Load()”,那么物体就会装上。

, 相关的问题建议,“Include”呼吁与条款之间可能发生冲突。 情况如何?

但无论如何,我如何调整这一询问,以装上“压力”和“契约”成员? 具体来说,我只想把成员装在retured物体上,而不是数据库中的所有“压力”和“反应”物体。

感谢。

<><>Edit>/strong>

我从把问题跟踪到使用多个。 条款

......

IQueryable<Property> currPropList 
            = from p in ve.Property
                            .Include("phyAddress")
              select p;

而“精神压力”成员被装上。

但是,这并不奏效......

IQueryable<Property> currPropList 
            = from p in ve.Property
                            .Include("phyAddress")
              from a in ve.ACLs
              select p;

基本上,当有多个从条款中删除时,就忽视了要求。 是否有任何人了解这方面的工作?

www.un.org/Depts/DGACM/index_spanish.htm Edit 2

一项工作是将 质量结果作为目标,并从中删除。 但我想防止我假设这一原因对数据库进行第二轮计算。

Eg. .......

IQueryable<Property> currPropList 
        = ((from p in ve.Property
          from a in ve.ACLs
          select p) as ObjectQuery<Property>).Include("phyAddress");

是否有办法只用一个问题来做到这一点?

<><>Edit 3

http://blogs.msdn.com/charlie/archive/2007/12/09/defered-execution.aspx“rel=”http://blogs.msdn.com/charlie/archive2/09/defered-execution.aspx。 因此,问题2将是解决办法。

问题回答

这是一个众所周知的问题,如果你做一些事情来改变问询的形式(即从那里)的话,那么就损失了包罗万象的工作:

  1. you can wrap the include around the query, see Tip 22 - How to make include really include.
  2. 或者你可以取得你在选定条款中所需要的一切,让关系确定能为你们工作。 i.e.

    var x = from p in ve.Property  
            from a in ve.ACLs  
            select new {p,p.phyAddress};  
    
    var results = x.AsEnumerable().Select(p => p.p);  
    

现在的成果是列举一些财产实体,但每个实体都装上了窒息装置,作为最初要求治疗的副作用,以及EF的关系设置。





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

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签