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