【发布时间】:2010-10-26 04:16:10
【问题描述】:
假设我有以下两个想要重构的 Linq 查询:
var someValue1 = 0;
var someValue2= 0;
var query1 = db.TableAs.Where( a => a.TableBs.Count() > someValue1 )
.Take( 10 );
var query2 = db.TableAs.Where( a => a.TableBs.First().item1 == someValue2)
.Take( 10 );
请注意,只有 Where 参数会发生变化。有什么方法可以将查询放在方法中并将 Where 参数作为参数传递?
【问题讨论】:
标签: c# .net linq linq-to-sql refactoring