MySQL Forums
Forum List  »  MySQL for Visual Studio

Issues with Entity Framework - MySQL LinQ Queries
Posted by: Tibin Thomas
Date: May 25, 2015 03:53AM

I am facing an issues while using ternary operator in where condition, along with group by clause in LinQ queries.
My application is MVC4 with Entity Framework 6(MySql.Data.Entity.EF6.dll version 6.9.6), connected to MySQL DB - 5.6.

A sample query listed here:

bool activeFlag = true;
var objCurrency = (from table in Db.Table.AsNoTracking()
where (activeFlag ? table.Active == 1 : table.Active == 0)
group table by table.Code into grp
select grp.OrderByDescending(t =>table.EffectiveFrom). FirstOrDefault()).ToList();

The query is working fine with MS SQL 2008 R2, but failed on MySql. The query is working if we remove either the ternery operator from where clause or if we remove the group by.

There are alternate methods to write the business logic but I have to re-write the code on lot of other places too. I am trying avoid the rework.

Please advice how to resolve this.. Is it a bug in EF MySQL provider.?

Options: ReplyQuote


Subject
Views
Written By
Posted
Issues with Entity Framework - MySQL LinQ Queries
2491
May 25, 2015 03:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.