C# Linq2Sql未对具有复合主键的实体使用标识缓存
您知道为什么Linq2Sql不对具有复合PK的对象使用标识缓存吗?通过这篇msdn文章()可以满足使用缓存的所有要求 示例代码:C# Linq2Sql未对具有复合主键的实体使用标识缓存,c#,caching,linq-to-sql,C#,Caching,Linq To Sql,您知道为什么Linq2Sql不对具有复合PK的对象使用标识缓存吗?通过这篇msdn文章()可以满足使用缓存的所有要求 示例代码: using (var context = new OrderingDataContext()) { var o1 = context.Orders.SingleOrDefault(x => x.SiteId == 1 && x.OrderId == 1119); //cache will not b
using (var context = new OrderingDataContext())
{
var o1 = context.Orders.SingleOrDefault(x => x.SiteId == 1 && x.OrderId == 1119);
//cache will not be used - PK SiteId + OrderId
var o2 = context.Orders.SingleOrDefault(x => x.SiteId == 1 && x.OrderId == 1119);
var s1 = context.Sites.SingleOrDefault(x => x.SiteId == 1);
//cache will be used - PK SiteId
var s2 = context.Sites.SingleOrDefault(x => x.SiteId == 1);
}
谢谢
维罗尼卡