当前位置:网站首页>A solution of C batch query

A solution of C batch query

2022-04-23 21:26:00 Plant a sweet smell

Business background :
Often receive similar needs from customers , The customer gave the internal staff of the company a excel, After that, you need to query the binding data or packaging data of the assembly line , There is no good interface for users to query
Solution :
1. Write SQL Script , Start splicing SQL, After that, it takes time and effort ;
2. The characters used in the text input box in the program are limited , about 5 More than 10000 data are powerless ;
New solution :
SqlSugar(ORM)+NPOI+sqlBulk( For big data (10 More than ten thousand ) Under the circumstances )

advantage :
1.SqlSugar(ORM) Provides an interface to interact with the database , And it's good to avoid sql Injection and sql error ; It's really quick to get started , Basically, if you look at the official documents and examples, you can almost ; this ORM It's open source. , quite a lot .NET All the big factories are using
SqlSuagr Official website address :http://www.codeisbug.com/Home
2.NPOI Provides operation methods for documents , And avoid not installing Microsoft excel The embarrassment of the special version , The specific packaging method is shown in MESCommon
3.sqlbulk Provide for the right to excel Operation of document mass data , Insert 100 10000 pieces of data to the database takes about 30S;
Compare the performance of mass data operations :
Code demo address :https://blog.csdn.net/baidu_29047977/article/details/90515682
3.SqlSugar It's a very useful Orm frame , In some performance , Better than Microsoft's EF The framework is also superior
matters needing attention
1. For operations with large data , Try not to use For loop ;
2. For batch query of data , Try to use the middle table ;

版权声明
本文为[Plant a sweet smell]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/110/202204200619556909.html