开发者

How to deal with duplicate anonymous type member conflicts?

I am creating an anonymous type and I have conflicting field names.

The follow开发者_如何学JAVAing code is failing because i.Name and i.Target.Name both have a property with the same name; "Name".

How do I get around this ? Here is the code:

i => new
{
    i.Name,
    i.Target.Name,
    i.EndDate,
    i.LastUpdated
};


Name the anonymous fields, as such:

new {Name = i.Name, targetName = i.Target.Name, ... };


 i => new
      {
          i.Name,
          TargetName = i.Target.Name,
          i.EndDate,
          i.LastUpdated
        });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜