我有一个具有以下定义的存储过程:
usp_totallisttype
select table1.name,table1.Id,table2.address,table1.type
from table1
inner join table2 on table1.Id = table2.Id
where (table1.type = 'A' OR table1.type = 'B')
order by table1.Id
CS :
public static List<classname> Getlist()
{
using (var Context = new DataContext())
{
var typelist = (from m in Context.Usp_totallisttype()
select new classname
{
name = m.name,
Id= m.Id,
address = m.address,
type = m.type
}).ToList();
if (typelist.Count > 0)
{
return typelist;
}
else
return null;
}
}
这里我调用 List() 方法:
List<classname> typeList = classname.List();
if (typeList != null)
{
var aList = typeList.where(p => p.type = "A").ToList();
//perform some opration and assign datasorce
var bList = typeList.where(p => p.type = "B").ToList();
//perform some opration and assign datasorce
}
问题 :
我怎样才能做到这一点:
var aList = typeList.where(p => p.type = "A").ToList();//How i can do this ?
//perform some opration and assign datasorce
var bList = typeList.where(p => p.type = "B").ToList();//How i can do this ?
//perform some opration and assign data source
我是 linq 的新手,所以请让我知道上面的代码中缺少某些内容或如何使其更优化。