Page 1 of 1

LINQ to Entity - can't compare string

Posted: Tue 05 Feb 2008 21:14
by Boffbowsh
Using Build 4.30.24.0 with Visual Studio 2008, Entity Framework beta 3 etc, the following simple code fails:

Code: Select all

        public static user Authenticate(string Username, string Password)
        {
            Entities context = new Entities(ConfigurationManager.ConnectionStrings["Entities"].ConnectionString);
            user user = (from u in context.user
                         where u.Username == Username
                         where u.Password == Password
                         select u).First();
            return user;
        }
Exception is:
Test method TestProject1.UserTest.AuthenticateTest threw exception: System.Data.CommandCompilationException: An error occurred while preparing the command definition, see the inner exception for details. ---> System.InvalidCastException: Specified cast is not valid..

Trace:
CoreLab.Common.Entity.e.a(TypeUsage A_0, String A_1, Int32& A_2)
CoreLab.Common.Entity.e.a(TypeUsage A_0, Int32& A_1)
CoreLab.Common.Entity.e.a(DbParameter A_0, TypeUsage A_1)
CoreLab.Common.Entity.e.b(DbParameter A_0, TypeUsage A_1)
CoreLab.Common.Entity.l.a(DbParameter A_0, KeyValuePair`2 A_1)
CoreLab.MySql.Entity.c.a(DbCommandTree A_0, DbConnection A_1)
CoreLab.MySql.Entity.MySqlEntityProviderServices.b(DbConnection A_0, DbCommandTree A_1)
System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbConnection storeConnection, DbCommandTree commandTree)
System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbConnection storeConnection, DbCommandTree commandTree)
System.Data.EntityClient.EntityCommand.CreateCommandDefinition()
System.Data.EntityClient.EntityCommand.GetCommandDefinition()
System.Data.EntityClient.EntityCommand.Prepare()
System.Data.EntityClient.EntityProviderServices.CreateDbCommandDefinition(DbConnection connection, DbCommandTree commandTree)
CreateExecutionInfo(ObjectContext context, DbQueryCommandTree tree, SpanIndex spanInfo, MergeOption mergeOption)
CreateExecutionInfo(DbQueryCommandTree tree, MergeOption mergeOption, Span span)
CreateExecutionInfo(MergeOption mergeOption, TypeUsage& resultType)
Compile(MergeOption mergeOption)
GetExecutionInfo(MergeOption mergeOption)
GetResults(MergeOption mergeOption)
GetResults()
GetEnumerator()
System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
b__0[TResult](IEnumerable`1 sequence)
System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
System.Linq.Queryable.First[TSource](IQueryable`1 source)
Model.user.Authenticate(String Username, String Password) in C:\Users\****\Documents\Visual Studio 2008\Projects\MySQLEntityTest\MSSQLEntityTest\User.cs: line 15
TestProject1.UserTest.AuthenticateTest() in C:\Users\****\Documents\Visual Studio 2008\Projects\MySQLEntityTest\TestProject2\UserTest.cs: line 73


The same conditions (as far as possible) using MSSQL works fine. Comparing by int works fine too:

Code: Select all

        public static user GetById(int Id)
        {
            Entities context = new Entities(ConfigurationManager.ConnectionStrings["Entities"].ConnectionString);
            user user = (from u in context.user
                         where u.UserID == Id
                         select u).First();
            return user;
        }
SQL for creating DB is at http://www.boffbowsh.co.uk/testdb.sql.txt

Any updated builds would be appreciated, we're currently evaluating the connector with a view to using it for our new systems.[/code]

Posted: Wed 06 Feb 2008 09:31
by Alexey.mdr
I couldn't reproduce the error.
Please send me a small test project to reproduce the problem.
It is desirable to use 'test' schema objects, otherwise include the
definition of your own database objects.
Do not use third party components.
If it is impossible for you to create the test project, send us a piece of
your code where the error occurs.

Posted: Wed 06 Feb 2008 10:14
by Boffbowsh
http://www.boffbowsh.co.uk/MySQLEntityTest.rar
This is the most basic project I could do that produces the problem. It doesn't contain anything that wasn't in my previous post.

Posted: Wed 06 Feb 2008 14:40
by Alexey.mdr
We will try to fix this bug in the nearest time.

Posted: Wed 06 Feb 2008 16:09
by Boffbowsh
I'd be willing to test any beta builds that might fix the issue.

Posted: Thu 07 Feb 2008 10:00
by Alexey.mdr
We have an intention to issue a new build next week.

Posted: Wed 13 Feb 2008 10:11
by Boffbowsh
Any updates on when you intend to issue a new build?

Posted: Wed 13 Feb 2008 13:17
by Alexey.mdr
Currently we are testing a new build.
Probably at the end of this week we will issue it.
But unfortunately the new build won't include a fix of the bug you are interested in.
The problem appears to be more complicated than expected, resulting in a solution delay.
We are still working on the problem. At this time we can't specify when exactly the bug will be fixed.

Posted: Wed 20 Feb 2008 10:39
by Boffbowsh
Sorry to keep hassling, any update on this?

Posted: Wed 20 Feb 2008 13:41
by Alexey.mdr
Yes, we have fixed the bug.
The build will be available for download next week.

Posted: Wed 20 Feb 2008 13:42
by Boffbowsh
Excellent news, thanks very much :)

Posted: Thu 21 Feb 2008 11:57
by Alexey.mdr
Welcome!
Look forward to the next build.
We will make an announcement soon.