转换实体收集到IList实体的地方收集未实现IEnumerable [英] Convert Entity Collection to Ilist where Entity Collection does not implement IEnumerable

查看:195
本文介绍了转换实体收集到IList实体的地方收集未实现IEnumerable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实体收藏就像这样:
EntityCollection 的用户;



我想将其转换为的IList 是这样的:

  systemUsers =新的List< CrmSdkTypeProxy.SystemUser>(); 



其中, CrmSdkTypeProxy.SystemUser 是一种类型的实体。然而,我的实体收藏是从 Microsoft.Xrm.Sdk DLL 导出code>不落实的IEnumerable 。我使用 MSCRM 2011具体的dll



任何?CrmSdkTypeProxy.SystemUser>


解决方案<的.List<:我如何创建一个列表这样的想法。/ DIV>

这为我工作



实体是一个 DataCollection<实体> ,你可以转换到的IEnumerable 然后使用了ToList 函数来创建一个匹配的的IList <您的名单/ code>您所需要的接口。

 返回service.RetrieveMultiple(查询)
.Entities
。选择(项目=> item.ToEntity< SystemUser>())
.ToList< SystemUser>();


I have a Entity Collection Like this: EntityCollection users;

I want to convert it to a Ilist like this:

systemUsers = new List<CrmSdkTypeProxy.SystemUser>(); 

where CrmSdkTypeProxy.SystemUser is a type of Entity. However, my Entity Collection is derived from a dll of Microsoft.Xrm.Sdk which does not implement IEnumerable. I am using mscrm 2011 specific dlls.

Any idea on how I create a list like this: .List<CrmSdkTypeProxy.SystemUser>?

解决方案

This worked for me.

Entities is a DataCollection<Entity> which you can convert into an IEnumerable and then use the ToList function to create your List which matches the IList interface that you require.

return service.RetrieveMultiple(query)
                                .Entities
                                .Select(item => item.ToEntity<SystemUser>())
                                .ToList<SystemUser>();

这篇关于转换实体收集到IList实体的地方收集未实现IEnumerable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆