Linq to sql立即加载
2010-07-13 14:55
232 查看
有时我们需要立即加载指定的关联数据。
DataLoadOptions loadOptions = new DataLoadOptions();
loadOptions.LoadWith<Customer>(it => it.Orders);
DataContext.LoadOptions = loadOptions;
DataContext.Log = Console.Out; // 用来查看请求的SQL语句,确定只发送一次请求。
LoadWith会将指定关联的数据全部加载,有时我们需要过滤关联数据怎么办?
使用DataLoadOptions的另一个方法AssociateWith<T>(Expression<Func<T, Object>>)。
DataLoadOptions loadOptions = new DataLoadOptions();
loadOptions.LoadWith<Customer>(it => it.Orders.Where(o=> o.ShippedDate != DateTime.Today));
DataContext.LoadOptions = loadOptions;
DataLoadOptions loadOptions = new DataLoadOptions();
loadOptions.LoadWith<Customer>(it => it.Orders);
DataContext.LoadOptions = loadOptions;
DataContext.Log = Console.Out; // 用来查看请求的SQL语句,确定只发送一次请求。
LoadWith会将指定关联的数据全部加载,有时我们需要过滤关联数据怎么办?
使用DataLoadOptions的另一个方法AssociateWith<T>(Expression<Func<T, Object>>)。
DataLoadOptions loadOptions = new DataLoadOptions();
loadOptions.LoadWith<Customer>(it => it.Orders.Where(o=> o.ShippedDate != DateTime.Today));
DataContext.LoadOptions = loadOptions;
相关文章推荐
- 步步为营VS 2008 + .NET 3.5(13) - DLINQ(LINQ to SQL)之用户自定义函数、在不同的DataContext之间做更新、缓存、获取信息、数据加载选项和延迟加载
- LINQ : 谈谈LINQ TO SQL中的直接加载和延迟加载
- LinqToSQL 关于延迟加载
- 立即升级你的 Linq to SQL -- Visual Entity 1.0 发布
- LINQ体验(12)——LINQ to SQL语句之对象标识和对象加载
- LINQ : 谈谈LINQ TO SQL中的直接加载和延迟加载
- LINQ to SQL语句(17)之对象加载
- LINQ体验(12)——LINQ to SQL语句之对象标识和对象加载
- LINQ体验(12)——LINQ to SQL语句之对象标识和对象加载
- LINQ体验(12)——LINQ to SQL语句之对象标识和对象加载
- LINQ to SQL语句(17)之对象加载
- 如何提高LINQ-to-SQL延时加载的性能
- LINQ体验(12)——LINQ to SQL语句之对象标识和对象加载
- 步步为营VS 2008 + .NET 3.5(13) - DLINQ(LINQ to SQL)之用户自定义函数、在不同的DataContext之间做更新、缓存、获取信息、数据加载选项和延迟加载
- 步步为营VS 2008 + .NET 3.5(13) - DLINQ(LINQ to SQL)之用户自定义函数、在不同的DataContext之间做更新、缓存、获取信息、数据加载选项和延迟加载
- LINQ to SQL系列三 使用DeferredLoadingEnabled,DataLoadOption指定加载选项
- LINQ体验(12)——LINQ to SQL语句之对象标识和对象加载
- [导入]LINQ体验(12)——LINQ to SQL语句之对象标识和对象加载
- 立即升级你的 Linq to SQL -- Visual Entity 1.0 发布