English 中文(简体)
LINQ - 我如何在选择发言中提及儿童的父母?
原标题:LINQ - How can I give a child object in a select statement a reference to its parent?
  • 时间:2010-06-22 16:10:30
  •  标签:
  • c#
  • linq

我试图这样做:

        List<FundEntity> entities = this.tFunds
            .Select(f => new FundEntity() {
               ID = f.fundID,
               Name = f.name,
               CapitalCalls = f.tCapitalCalls
                    .Select(cc => new CapitalCall() {
                        ID =  cc.capitalCallID,
                        Description = cc.description,
                        FundEntity = // Should be the newly created Fund Entity object
                    }).ToList()                   
            }).ToList();

我希望每次资本呼吁都提及其资金意向。 如果不创建一种 lo和以人工方式确定每一?,这是否可行?

问题回答
List<FundEntity> entities = this.tFunds
        .Select(f => 
        {
           var parent = new FundEntity() {
               ID = f.fundID,
               Name = f.name,
               };
           parent.CapitalCalls = f.tCapitalCalls
                    .Select(cc => new CapitalCall() {
                    ID =  cc.capitalCallID,
                    Description = cc.description,
                    FundEntity =parent // Should be the newly created Fund Entity object
                });
            return parent;
        }.ToList()                   
        ).ToList();

这应当提到你。

准则是否用于实体/实体/实体?

  • 在第一种情况下,你只能创建该实体,然后制定其<代码>CapitalCalls,财产必须(例如,Stephan)

  • 在第二起案件中,恐怕在LINQ的询问中没有这样做的途径(因为你不能提及你在创建时重新制造的物体,但你不能使用多种说法,因为翻译不支持。 但是,你可以很容易地修改贵国的数据库或实体模式,以包含你们所需要的参考资料......





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

热门标签