1、延迟加载原来的查询方式如下:IEnumerableusers = session .Query () .Where(x => x.Name == "john");延迟加载方式:Lazy > lazyUsers = session .Query () .Where(x => x.Name == "John") .Lazily();IEnumerable users = lazyUsers.Value;//一次执行所有延迟操作IEnumerable users = null;IEnumerable cities = null; session .Query () .Where(x => x.Name == "John") .Lazily(x => users = x); session .Query () .Where(x => x.Name == "New York") .Lazily(x => cities = x); session.Advanced.Eagerly.ExecuteAllPendingLazyOperations();//lucene的也支持Lazy > users = session.Advanced .LuceneQuery () .WhereEquals("Name", "John") .Lazily();2、交集在服务端进行交集操作,只返回符合全部条件的数据session.Query ("TShirtIndex") .Where(x => x.Manufacturer == "Raven") .Intersect() .Where(x => x.Types.Any(t => t.Color == "Blue" && t.Size == "Small")) .Intersect() .Where(x => x.Types.Any(t => t.Color == "Gray" && t.Size == "Large")) .ToList();或者这么写session.Advanced.LuceneQuery ("TShirtIndex") .Where("Manufacturer:Raven INTERSECT Color:Blue AND Size:Small INTERSECT Color:Gray AND Size:Large") .ToList();3、禁止缓存和跟踪session.Query ().Customize(x => x.NoCaching());session.Query ().Customize(x => x.NoTracking());4、动态聚合假设我们有一条这样的sql语句select sum(Total) from Orders where Total > 500 group by Productlinq的写法是:var result = session.Query ("Orders/All") .Where(x => x.Total > 500) .AggregateBy(x => x.Product) .SumOn(x => x.Total) .ToList();store的store.DatabaseCommands.PutIndex("Orders/All", new IndexDefinitionBuilder (){ Map = orders => from order in orders select new { order.Total, order.Product, order.Concurrency }, SortOptions = { { x => x.Product, SortOptions.Double } }});扩展查询:result = session.Query ("Orders/All") .AggregateBy(x => x.Product) .AddRanges(x => x.Total < 100, x => x.Total >= 100 && x.Total < 500, x => x.Total >= 500 && x.Total < 1500, x => x.Total >= 1500) .SumOn(x => x.Total) .ToList();result = session.Query ("Orders/All") .AggregateBy(x => x.Product) .SumOn(x => x.Total) .CountOn(x => x.Total) .AndAggregateOn(x => x.Concurrency) .MinOn(x => x.Total) .ToList();result = session.Query ("Orders/All") .AggregateBy(x => x.Product) .SumOn(x => x.Total) .CountOn(x => x.Total) .AndAggregateOn(x => x.Concurrency) .MinOn(x => x.Total) .ToList();