Linq to sql 如何在LINQ to Sql结果上按数据lambda分组?
我像这样从数据库中获取数据Linq to sql 如何在LINQ to Sql结果上按数据lambda分组?,linq-to-sql,lambda,group-by,Linq To Sql,Lambda,Group By,我像这样从数据库中获取数据 Dim query = From t1 In TBL1 _ Join t2 In TBL2 On t1.ID Equals t2.ID _ Join t3 In TBL3 On t1.ID Equals t3.ID _ Group Join t4 In t1 _ On t1.ID Equals t4.ID _ In
Dim query = From t1 In TBL1 _
Join t2 In TBL2 On t1.ID Equals t2.ID _
Join t3 In TBL3 On t1.ID Equals t3.ID _
Group Join t4 In t1 _
On t1.ID Equals t4.ID _
Into t4_Grp = Group _
Select t1, t2, t3, t4_Grp
query = query.Where(Function(o) o.t1.ID = lngID)
Dim query = From t1 In TBL1 _
Join t2 In TBL2 On t1.ID Equals t2.ID _
Join t3 In TBL3 On t1.ID Equals t3.ID _
Group Join t4 In t1 _
On t1.ID Equals t4.ID _
Into t4_Grp = Group _
Select t1, t2, t3, t4_Grp
query = query.Where(Function(o) o.t1.ID = lngID)
我以前用过这个来做一些力量分组
private void ProducePivotAnalytic <T, K>(IEnumerable<T> colletion, Func<T, K> pivot)
{
var grouped =
from n in colletion
group n by pivot(n) into g
select new { theKey = g.Key, theValue = g };
// do some stuff with your grouped collection.
}
ProducePivotAnalytic<List<DateTime>, DayOfWeek>(
myDates,
(x) => (x.DayOfWeek) );
private void producePivotAnalysis(IEnumerable Collection,Func pivot)
{
var分组=
从n开始
按轴(n)将n分组为g
选择new{theKey=g.Key,theValue=g};
//对你的分组收藏做一些事情。
}
生产数据分析(
myDates,
(x) =>(x.DayOfWeek));
请澄清您的问题,您所说的“使用lambda表达式”或“lambda the t4_Grp”是什么意思?您是否正在尝试进行额外过滤,但在表t4而不是t1上?是的,我正在尝试进行额外过滤;在t4_Grp上。