English 中文(简体)
实体数据示范协会和MVC 1 NET ,向法国国家排雷中心提供相关物品,但允许林克实体进行过滤
原标题:Entity Data Model Associations and MVC 1 .NET giving NULL on Associated objects but allowing Linq to Entities Filtering

我拥有2005年快车库数据库中产生的EDM。 例如,我有一个表格,名为与一个名为“人民”的表格有关系的项目。 各个项目在人民议席上有着两个主要关系,即人民议席(ChamipionID和领导人ID)。

我已经清理了各实体、实体小组和协会的所有名称,并核实协会的制图是我预期的。

当我向实体致函询问此事时,“Leader”协会在MVC 1网站上总是将数据类型64(长期)的“Leader”向人民ID进行测绘。

例如

var object = (from p in _entities.Projects 
              where p.Leader.PeopleID == 1 
              select p); 

是的,永远无效。 领导人,即使协会允许过滤正确进行,项目数据也全部公布。

即便如此,我也这样说。

var object = (from p in _entities.Projects 
              from pe in _entities.PeopleSet 
              where pe.PeopleID == 1 
              select p);

结果是相同的。

谁知道发生这种情况? 我失踪了什么?

最佳回答

EF 1将永远不会装上相关类别,除非你强迫。

我强烈建议从实体类别中删除你的意见。 然后,你可以强制装上正确的财产(和 只限)。 通过预测:

var object = (from p in _entities.Projects 
              where p.Leader.PeopleID == 1 
              select new ViewModel
              {
                  ProjectName = p.Name,
                  LeaderName = p.Leader.Name
              });

现在,领导人将装上手势,你的观点是坚持不懈的。

问题回答

在接触物体时也可以这样做:

if (!entity.Project.IsLoaded) entity.Project.Load();

作为一种另一种选择,这显然是在定点一级。





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

热门标签