[英]Copying Data from Microsoft CRM SDK collection to a CSV file or Excel File. (data-dump)
Here is the information about the development environment pertaining to my work computer: 以下是与我的工作计算机有关的开发环境的信息:
-Microsoft Visual Studio Enterprise 2015 Version 14.0.35123.00 Update 2 -Microsoft Visual Studio Enterprise 2015版本14.0.35123.00更新2
-Microsoft Dynamics CRM installed on a remote server. -在远程服务器上安装的Microsoft Dynamics CRM。
Our ASP.NET C# application communicates to the Microsoft Dynamics CRM server using the Microsoft CRM SDK. 我们的ASP.NET C#应用程序使用Microsoft CRM SDK与Microsoft Dynamics CRM服务器通信。
I'm trying to do analysis of data by grabbing a large collection of information that our ASP.NET C# application retrieves from the Microsoft Dynamics CRM server. 我试图通过获取ASP.NET C#应用程序从Microsoft Dynamics CRM服务器检索的大量信息来进行数据分析。
In the following snapshot picture, the C# code retrieves data from Microsoft Dynamics CRM using a result object of type Microsoft.Xrm.Sdk.EntityCollection: 在下面的快照图片中,C#代码使用类型为Microsoft.Xrm.Sdk.EntityCollection的结果对象从Microsoft Dynamics CRM中检索数据:
Could someone please tell me how I could quickly just programmatically copy the data in the said collection to a csv file or an Excel file? 有人可以告诉我如何快速以编程方式将所述集合中的数据复制到csv文件或Excel文件吗?
Writing it to file is the easiest part, use StringBuilder iterate through all the attributes to build a string and use File.WriteAllText and write all the data to the file. 将其写入文件是最简单的部分,使用StringBuilder遍历所有属性以构建字符串,并使用File.WriteAllText并将所有数据写入文件。 But the big question is in what format?
但是最大的问题是什么格式? If you cannot read back what you have written there is no point in writing all the data to a file.
如果您无法读回已写的内容,则没有必要将所有数据写到文件中。 Converting SDK objects to JSON string is a bit tricky.
将SDK对象转换为JSON字符串有点棘手。
I'd suggest to flatten the objects out (DTO) serialize it to JSON and write it to the file, so you can read it out and re-convert it to an SDK type easily. 我建议将对象展平(DTO),将其序列化为JSON并将其写入文件,以便您可以读取并轻松将其重新转换为SDK类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.