DbLinq 问题(关键字 New 或 MemberInit 引发异常)
我正在将一个巨大的 Web 应用程序从 SQL Server 迁移到 MySql。 该应用程序使用 Linq,所以我使用 DBLinq。 目前大多数事情都工作正常,除了在几页上我收到一个奇怪的错误。 一切都是从这个开始的:
Property 'Int32 ForumID' is not defined for type 'DbLinq.Data.Linq.Table`1[CPost]'
我显然在 CPost 类中有一个 ForumID,所以这不是问题。 我尝试将查询复制到一个单独的文件中,并开始删除其中的一部分以查看导致错误的原因。 一段时间后,我发现这一行:
var q = from u in db.Users select new {ab = u};
引起了异常:
New
在该行:
throw new ArgumentException(operationType.ToString());
Source File: D:\Visual Studio 2008\Projects\DbLinq\src\DbLinq\Data\Linq\Sugar\Implementation\ExpressionDispatcher.Analyzer.cs Line: 858
但是这段代码:
var q = from u in db.Users select u;
完美运行。
如果需要,我可以提供更多信息,但我无法发布整个源代码,因为它非常庞大(超过 10,000 行,不包括 html)。 有人遇到过类似的问题吗?
中找到关键字 New 或 MemberInit
var q = db.Posts.Select(post => post);
编辑:经过进一步调查,我发现 DbLinq 会抱怨,因为它没有从查询Works while:
var q = db.Posts.Select(o => new SPost {Post = o});
:并
var q = db.Users.Select(u => new {user = u});
抛出异常。 例外情况发生在 285 在 trunk/src/DbLinq/Vendor/Implementation/SqlProvider.cs
I'm migrating a huge web application from SQL Server to MySql. The application uses Linq so i'm using DBLinq. Currently most things are working properly except for that on a few pages i get a strange error. It all started with this:
Property 'Int32 ForumID' is not defined for type 'DbLinq.Data.Linq.Table`1[CPost]'
I've obviously got a ForumID in the CPost class, so that isn't the problem. I tried copying the query to a separate file and started removing parts of it to see what caused the error. After a while i found out that this line:
var q = from u in db.Users select new {ab = u};
Caused a exception:
New
At the line:
throw new ArgumentException(operationType.ToString());
Source File: D:\Visual Studio 2008\Projects\DbLinq\src\DbLinq\Data\Linq\Sugar\Implementation\ExpressionDispatcher.Analyzer.cs Line: 858
But this code:
var q = from u in db.Users select u;
Ran Perfectly.
I can provide more information if it's needed however i can't post the entire source code since it's quite huge (above 10,000 lines not counting html). Have anyone had similar problems to these?
EDIT: After some further investigation i found that DbLinq complains because it does not find the keyword New or MemberInit from the query
var q = db.Posts.Select(post => post);
Works while:
var q = db.Posts.Select(o => new SPost {Post = o});
and
var q = db.Users.Select(u => new {user = u});
Throws an exception. The exception is made at line 285 in trunk/src/DbLinq/Vendor/Implementation/SqlProvider.cs
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会避免在生产代码中使用 DBLinq...Linq-To-SQL 的许多功能都未实现,并且浏览源代码显示成熟度较低...许多方法未实现或标记为“未终止”。
……你已被警告过!
I'd avoid using DBLinq for production code... many of Linq-To-SQL's features aren't implemented, and walking through the source code shows a low level of maturity... many of the methods are not implemented or marked as "unterminated".
...you've been warned!