在Microsoft Dynamic 365/2016环境使用LinqPad查询数据(不使用linqpad Microsoft Dynamic 365 Driver)
Posted xiefengdaxia123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Microsoft Dynamic 365/2016环境使用LinqPad查询数据(不使用linqpad Microsoft Dynamic 365 Driver)相关的知识,希望对你有一定的参考价值。
在Microsoft Dynamic 365/2016环境使用LinqPad查询数据
老规矩,先上效果图:
实体集合:
实体属性:
属性值:
查询出的结果可以导出的格式:
操作步骤:
1、下载LinqPad工具:下载地址
2、打开LinqPad,按F4快捷键添加引用
3、添加命名空间的引用
4、新增查询,语言选择为program
5、分享一波代码
void Main() { var url = "http://ip:port/orgname/XRMServices/2011/Organization.svc"; var userName = "用户名"; var pwd = "密码"; var serviceProxy = GetOrganizationService(url, userName, pwd); serviceProxy.EnableProxyTypes(); var service = (IOrganizationService)serviceProxy; Execute(service); } static void Execute(IOrganizationService service) { OrganizationServiceContext context1 = new OrganizationServiceContext(service); var query = from a in context1.CreateQuery("systemuser") where a["systemuserid"].Equals("044B5543-98C0-E811-8DA1-005056809B25") //select new //{ // new_monthplanchangeid = a["new_monthplanchangeid"] //}; //select new { name=a["name"]}; select a; var list = query.ToList(); list.Dump(); } /// <summary> /// 获取组织服务 /// </summary> /// <param name="OrgUrl">服务地址</param> /// <param name="UserName">用户名</param> /// <param name="PassWord">账号</param> /// <returns></returns> public static OrganizationServiceProxy GetOrganizationService(string OrgUrl, string UserName, string PassWord) { ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; Uri organizationUriIfd = new Uri(OrgUrl); var credentials = new ClientCredentials(); credentials.UserName.UserName = UserName; credentials.UserName.Password = PassWord; var config = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(organizationUriIfd); return new OrganizationServiceProxy(config, credentials); }
6、执行
以上是关于在Microsoft Dynamic 365/2016环境使用LinqPad查询数据(不使用linqpad Microsoft Dynamic 365 Driver)的主要内容,如果未能解决你的问题,请参考以下文章
microsoft dynamic CRM2016安装时报错组件未安装
Report processing of Microsoft Dynamic AX
Microsoft Dynamic 报表应用report builder 实例
Microsoft dynamic crm安装前需要装啥东西?求一个教程