调用Andrus:LINQ-to-SQL id查询 [英] Calling Andrus : LINQ-to-SQL id queries

查看:78
本文介绍了调用Andrus:LINQ-to-SQL id查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很久以前我们在

LINQ-to-SQL中讨论了基于id的查询的问题;作为更新,现在建议将其修复为3.5

SP1。


完整信息:
http://blogs.msdn.com/dinesh.kulkarn...nq-to-sql.aspx


Marc

A long time ago we discussed an issue with id-based queries in
LINQ-to-SQL; as an update, it is now suggested that this is fixed in 3.5
SP1.

Full info:
http://blogs.msdn.com/dinesh.kulkarn...nq-to-sql.aspx

Marc

推荐答案

好吧,部分修复;-p


单(pred)是固定的,但是哪里(pred)。单身()还是往返;对于

来自Northwind的例子见下文。


Marc


使用(NorthwindDataContext ctx = new NorthwindDataContext())

{

ctx.Log = Console.Out;

Console.WriteLine(" Find first employee ...");

var emp1 = ctx.Employees.First();

int id = emp1.EmployeeID;

Console.WriteLine(" Where(pred) )=>单个);

for(int i = 0; i< 10; i ++)

{

var emp2 = ctx.Employees.Where(x = x.EmployeeID ==

id).Single();

}

Console.WriteLine(" ;单(pred)");

for(int i = 0; i< 10; i ++)

{

var emp3 = ctx.Employees.Single(x = x.EmployeeID

== id);

}

Console.WriteLine(" Exit" );

}
Well, part fixed ;-p

Single(pred) is fixed, but Where(pred).Single() still round-trips; for
example via Northwind see below.

Marc

using (NorthwindDataContext ctx = new NorthwindDataContext())
{
ctx.Log = Console.Out;
Console.WriteLine("Find first employee...");
var emp1 = ctx.Employees.First();
int id = emp1.EmployeeID;
Console.WriteLine("Where(pred)=>Single");
for (int i = 0; i < 10; i++)
{
var emp2 = ctx.Employees.Where(x =x.EmployeeID ==
id).Single();
}
Console.WriteLine("Single(pred)");
for (int i = 0; i < 10; i++)
{
var emp3 = ctx.Employees.Single(x =x.EmployeeID
== id);
}
Console.WriteLine("Exit");
}


Marc,
Marc,

嗯,部分修复; - p />

单(pred)是固定的,但Where(pred).Si ngle()仍然往返;对于

来自Northwind的例子见下文。
Well, part fixed ;-p

Single(pred) is fixed, but Where(pred).Single() still round-trips; for
example via Northwind see below.



谢谢。

我创建了代码生成器,它使用静态创建代码来实现缓存

Dictionary< entityId ,每个属性的值属性。

每个实体的每个实体都包含静态getter方法,它首先执行
缓存查找。

所以我做'' nt依赖于DLinq缓存。

在winforms appl中使用DLinq缓存的唯一方法是使用应用程序

宽全局DataContext类仅用于检索和缓存。

但是这可能不合理,因为它不允许部分清除

缓存。


顺便说一句。哪里可以找到有关winforms的信息?

我只发现添加了多个新控件,没有更多。


Andrus。

Thank you.
I created code generator which creates code to implement cache using static
Dictionary<entityId,value properties for every property.
Every entity every property contains static getter method which performs
cache lookup first.
So I do''nt rely on DLinq cache.
The only way to use DLinq cache in winforms appl would be to use application
wide global DataContext class for retrieve and cache only.
However this is probably not reasonable since it does not allow to clear
cache partially.

Btw. Where find information about winforms changes ?
I have only found that there are number of new controls added, no more.

Andrus.


顺便说一句。哪里可以找到有关winforms的信息?
Btw. Where find information about winforms changes ?

我只发现添加了多个新控件,没有更多。
I have only found that there are number of new controls added, no more.



真的吗?哪个?老实说,我不期待任何突破性的开发 - 大部分推力似乎都是针对WPF和

Silverlight。我真的必须给他们好好看看吧!


Marc

Really? Which ones? I honestly don''t expect any ground-breaking
winform developments - much of the thrust seems to be towards WPF and
Silverlight. I really must give them a good look at some point!

Marc


这篇关于调用Andrus:LINQ-to-SQL id查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆