SQL CLR存储过程输出
有一个名为User的简单类及其对象列表SQL CLR存储过程输出,sql,clr,sqlclr,Sql,Clr,Sqlclr,有一个名为User的简单类及其对象列表 公共类用户 { 公共int ID; 公共字符串用户名; 公共字符串用户密码; } ... List userList=新列表(); 我是否可以将此用户对象列表作为执行SLQ CLR存储过程的结果? e、 我想要这个 ID UserName UserPassword 1 Ted SomePassword 2 Sam Password2 3 Bill dsdsd ID用户名用户密码 1.密码 2山
公共类用户
{
公共int ID;
公共字符串用户名;
公共字符串用户密码;
}
...
List userList=新列表();
我是否可以将此用户对象列表作为执行SLQ CLR存储过程的结果?
e、 我想要这个
ID UserName UserPassword
1 Ted SomePassword
2 Sam Password2
3 Bill dsdsd
ID用户名用户密码
1.密码
2山姆密码2
3条例草案
[SqlProcedure]
公共静态void GetAllocations()
{
//这里是什么??
}
另外,请不要建议我使用Sql函数。它不适合我,因为它不支持输出参数
p.S.2如有任何帮助,我将不胜感激 尝试使用创建虚拟表,并通过对象的属性发送:
你看过林克吗?马塞尔·J·克鲁伯特。我真的很感激你!!!非常感谢!你救了我的命)
ID UserName UserPassword
1 Ted SomePassword
2 Sam Password2
3 Bill dsdsd
[SqlProcedure]
public static void GetAllocations()
{
// what here ??
}
[SqlProcedure]
public static void GetAllocations()
{
// define table structure
SqlDataRecord rec = new SqlDataRecord(new SqlMetaData[] {
new SqlMetaData("ID", SqlDbType.Int),
new SqlMetaData("UserName", SqlDbType.VarChar),
new SqlMetaData("UserPassword", SqlDbType.VarChar),
});
// start sending and tell the pipe to use the created record
SqlContext.Pipe.SendResultsStart(rec);
{
// send items step by step
foreach (User user in GetUsers())
{
int id = user.ID;
string userName = user.UserName;
string userPassword = user.UserPassword;
// set values
rec.SetSqlInt32(0, id);
rec.SetSqlString(1, userName);
rec.SetSqlString(2, userPassword);
// send new record/row
SqlContext.Pipe.SendResultsRow(rec);
}
}
SqlContext.Pipe.SendResultsEnd(); // finish sending
}