简体   繁体   English

将批量插入添加到Web API

[英]Adding Bulk Inserting to Web API

We have an API that companies use to add products to our catalog system. 我们有一个API,供公司用于将产品添加到目录系统中。

The issue is that currently it is a 1 item at a time setup, which to a vendor that will input 10-20k entries at a time, is a massive pain. 问题在于,当前每次设置仅一项,对于一次将输入10-20k条目的供应商来说,这是一个巨大的难题。

I'm looking to add a bulk option to the api but unsure how to add synch support to this. 我想向api添加批量选项,但不确定如何向其中添加同步支持。

I'm using MVC 5 & Web API 2 and .NET 4.5 我正在使用MVC 5和Web API 2和.NET 4.5

Everything I find on this is talking about uploading not bulk inserting records. 我发现的所有内容都是关于上传而不是批量插入记录。

EDIT: 编辑:

I should add that the user would be chunking the data to 20-50 records at a time. 我应该补充一点,用户将一次将数据分块为20-50条记录。

You are probably finding those references to uploads due to the fact that the best way to handle what you describe is to provide functionality to upload a file of products and then process the file server side. 您可能会找到这些对上传的引用,原因是处理您所描述内容的最佳方法是提供上传产品文件然后处理文件服务器端的功能。

If you add a method to accept a blob of 20k entries in your api then you will have to set your max http request/json size to an astronomical number. 如果您在api中添加了一种接受20k条目的方法,则必须将您的最大http请求/ json大小设置为天文数字。 Not to mention it is a daunting task to provide feedback to the client while the data is being transferred. 更不用说在数据传输时向客户端提供反馈是一项艰巨的任务。

By using an async file upload you can provide file transfer progress to the user and the whole process will be less error prone. 通过使用异步文件上传,您可以向用户提供文件传输进度,并且整个过程不易出错。 You can break the processing into chunks. 您可以将处理分为多个块。

Bulk insert/copy is more of a database term that describes a more efficient way to upload large data into a database. 批量插入/复制更多地是数据库术语,它描述了一种将大数据上传到数据库的更有效的方法。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM