如何通过的℃的数组;列表>存储过程 [英] How to pass an array of <List> to a stored procedure

查看:130
本文介绍了如何通过的℃的数组;列表>存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表的 ClaimData在C#,它有三个项目的日期,类型和说明
有可能在这下面,

I have a list ClaimData in C# and it has three items Date, Type and Description There can be multiple rows in this as below,

ClaimData

Date         Type      Description

01/02/2012  "Medical" "Its a medical"
05/02/2013  "Theft"   "Its a Theft"
01/02/2014  "Test"    "Its a Test"

我想这整个数据传递给存储过程一气呵成到SQL Server,这样我就可以减少数据库命中。我已经写存储过程可通过此列表迭代,在一个表中插入。

I want to pass this whole data to a stored procedure in one go to the sql server, so that I can reduce the database hits. I have written stored procedure which can iterate through this list and insert them in a table.

如何通过操纵列表对象来实现,可以传递给存储过程作为?参数

How to achieve by manipulating the list object could be passed to the stored procedure as a parameter?

推荐答案

我发送的所有三栏作为一个字符串使用字符串生成器和分隔符|

I sent all three column as a string using string builder and delimeter '|'

    DateString = '01/02/2012|05/02/2013|01/02/2014'
    TypeString = 'Medical|Theft|Test'
    DescString = "Its a medical|..."

在数据库方面我用功能分隔这些字符串,并在临时表中插入的所有这些值。这解决了我的问题。

On database side I used a function to delimit these strings and inserted all these values in a temp table. This solved my problem.

这篇关于如何通过的℃的数组;列表>存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆