简体   繁体   English

使用C#在SQL Server中保存数据的最快方法是什么?

[英]What is the fastest way to save data in SQL Server using C#?

I am currently working on a small .NET app in C#, that fetches data through some web service. 我目前正在使用C#开发一个小型.NET应用程序,该应用程序通过某些Web服务获取数据。

The data is represented in objects, so it would have been logical to store the data in a document based database, but there is a demand to use SQL Server. 数据以对象表示,因此将数据存储在基于文档的数据库中是合乎逻辑的,但是有使用SQL Server的需求。

So what might be the fastest way to insert many thousands, perhaps millions of rows into a database. 因此,将数以千计,也许数百万行插入数据库的最快方法可能是。

I an open to any framework, that might could support that, but I haven't been able to find any benchmarking on this eg on Entity Framework. 我对任何框架都持开放态度,这可能会支持这一框架,但是我无法在此上找到任何基准,例如在实体框架上。

To iterate over the data an do an insert per row is simply to slow, then it would be quicker to dump the data in a file, and then do a bulk import using SSIS, but for this scenario I would rather avoid that, and keep all logic in the C# app. 要遍历数据,每行插入一次只是为了减慢速度,然后将数据转储到文件中,然后使用SSIS进行批量导入会更快,但是对于这种情况,我宁愿避免这种情况,并保持C#应用程序中的所有逻辑。

You might want to use the SqlBulkCopy class. 您可能要使用SqlBulkCopy类。 It is quite efficient for large data. 对于大数据而言,这非常有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从C#在SQL Server中插入记录的最快方法是什么 - What is the fastest way to insert record in SQL Server from C# 在 SQL Server(C# 客户端)中批量插入大量数据的最快方法是什么 - What's the fastest way to bulk insert a lot of data in SQL Server (C# client) 从数据库SQLite C#服务堆栈读取SQL数据(数百万条记录)的最快方法是什么 - What is the fastest way to read the SQL Data (Millions of records) from database SQLite C# Service Stack 在SQL Server CE Winforms中查找数据的最快方法是什么 - What is fastest way to find data in SQL Server CE Winforms C#将数据插入SQL数据库的最快方法 - C# fastest way to insert data into SQL database 在 c# 中为 Vector256 准备数据的最快方法是什么 - What is the fastest way to prepare data for Vector256 in c# 在Windows Mobile(使用C#)中的SQLCE中查找数据的最快方法是什么? - What is the fastest way to find data in SQLCE in Windows Mobile (using C#)? 使用C#将Bulk Xml(XElement)数据插入Sql server Table的最佳方法是什么? - What is the best way to insert Bulk Xml (XElement) data to Sql server Table using C#? 目前可以使用C#4.0从SQL Server检索数据的方法是什么? - What is the currently accepted way to retrieve data from a SQL Server using C# 4.0? 使用C#将XML文件加载到MySQL的最快方法是什么? - What is the fastest way to load an XML file into MySQL using C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM