sqlclr创建表值函数案例

----------------------------------------------:定义表值类型:(1.一定返回的是IEnumerable2.一定带参数3.一定有FillRowMethodName和TableDefinition参数)
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction(DataAccess=DataAccessKind.Read, TableDefinition="Name nvarchar(100),ClassName nvarchar(100)",FillRowMethodName="FillTable",IsDeterministic=true)]
public static IEnumerable TableTest(SqlString str)
{

ArrayList list =new ArrayList{

new Student{ Name="郭泽峰",ClassName="沈阳理工大学103361"},
new Student{Name="郭泽峰1",ClassName="沈阳理工大学103361"},
new Student{Name="郭泽峰2",ClassName="沈阳理工大学103361"},
};
return list;
}
public static void FillTable(object obj, out SqlString name, out SqlString className)
{
Student s = obj as Student;
name = "";
className = "";
if (s != null)
{
name = s.Name;
className = s.ClassName;
}
}
};

上一篇:Linux中“!"的神奇用法


下一篇:【Go语言系列】1.1、GO语言简介:什么是GO语言