Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF 6 with MySql - error #138

Open
Nesse opened this issue Jun 21, 2022 · 5 comments
Open

EF 6 with MySql - error #138

Nesse opened this issue Jun 21, 2022 · 5 comments

Comments

@Nesse
Copy link

Nesse commented Jun 21, 2022

Hi,

I'm using an implementation of EF 6 using a MySql database. This works great. But now I want to use a BreezeController and here I'm getting some errors => String was not recognized as a valid Boolean value

This is only with some requests using the $expand parameter. This is my request:

Products?$filter=(Id eq 576) and (Deleted eq false)&$expand=ProductPictures,ProductCategories,ProductManufacturers,ProductSpecificationAttributes,ProductTierPrices,StockItems/StockUnits/WarehouseLocation,RelatedProducts,CrossSellProducts,BundledProducts,GroupedProducts,ProductPurchasePrices,ProductGroup,ProductTranslations

I've did some debugging and see that the error message comes from Beeze.WebApi2.QueryHelper:

var listQueryResult = Enumerable.ToList((dynamic)queryResult);

Here is my EF setup:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
 
    modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); 
    modelBuilder.Properties<decimal>().Configure(c => c.HasPrecision(18, 10));
    modelBuilder.Properties<string>().Configure(c => c.HasColumnType("LONGTEXT"));
    modelBuilder.Properties<bool>().Configure(c => c.HasColumnType("BIT"));

    // base
    base.OnModelCreating(modelBuilder);
}

Does someone knows how to fix this?

@steveschmitt
Copy link
Member

At first glance, it seems like the error might be caused by Deleted eq false. What happens if you use Deleted eq 0 ?

@Nesse
Copy link
Author

Nesse commented Jun 22, 2022

At first glance, it seems like the error might be caused by Deleted eq false. What happens if you use Deleted eq 0 ?

@steveschmitt The error is the same. I Think this is an issue using $expand with more than 1 level deep.

@Nesse
Copy link
Author

Nesse commented Jun 22, 2022

After some more digging I think the problem is caused by the MySql Connector (MySql.Data.EntityFramework). What are your thoughts?

   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
   at System.Convert.ToDecimal(String value, IFormatProvider provider)
   at System.String.System.IConvertible.ToDecimal(IFormatProvider provider)
   at System.Convert.ToDecimal(Object value)
   at MySql.Data.MySqlClient.MySqlDataReader.GetDecimal(Int32 i)
   at MySql.Data.EntityFramework.EFMySqlDataReader.GetDecimal(Int32 ordinal) 

@steveschmitt
Copy link
Member

Strange that the error is "String was not recognized as a valid Boolean value", but the stack trace shows that it is trying to convert a field to a decimal.

It looks like the error is happening when it is reading the results, so perhaps one of the table fields is mapped to an incompatible C# type. But which one? You may have to remove your expands one at a time until you find which table has the problem.

@steveschmitt
Copy link
Member

Any new info on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants