C#LINQ dynamic Query转换为存储过程

时间:2017-03-03 06:25:31

标签: c# sql-server linq stored-procedures

我是SQL新手并尝试将C#linq查询转换为存储过程。

Linq查询如下所示:

if (subscription.address1 != null) 
   address1 = subscription.CountryNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();

if (subscription.address2 != null) 
   address2= subscription.CountryNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();

var query = context
               .Information
               .Where(item => item.AppearanceDate >= dateFromDT && item.AppearanceDate <= dateToDT);

if (address1.Count > 0)
    query = query.Where(item => address1.Contains(item.address1));

if (address2.Count > 0)
    query = query.Where(item =>  address2.Contains(item.address2));

var results = query.select.toList()

表名:信息

专栏:

Person_Name
address1
address2

address2address1传入

如何为此编写存储过程?

我必须为每个地址和查询创建一个#Temp表吗?提前致谢

0 个答案:

没有答案