Compiled Query操作
说明:在之前我们没有好的方法对写出的SQL语句进行编辑重新查询,现在我们可以这样做,看下面一个例子:
//1.创建compiled query NorthwindDataContext db = new NorthwindDataContext(); var fn =CompiledQuery.Compile( (NorthwindDataContext db2, string city) => from c indb2.Customers where c.City == city select c); //2.查询城市为London的消费者,用LonCusts集合表示,这时可以用数据控件绑定 var LonCusts = fn(db, "London"); //3.查询城市为Seattle的消费者var SeaCusts = fn(db, "Seattle");