score:2
the exception is because of you saved your mysql enum value as string true
, false
and this is not parsed by enum in c# so that error comes.
so if there is possible then change the enum in mysql like
`reconciled` enum(1,0) not null default 0
and then set your c# enum member value to 0
,1
like
public enum bankaccountreconciled
{
[display(name = "true")]
true = 1, //<= set 1 for true that equivalent to mysql enum value 1
[display(name = "false")]
false = 0 //<= set 0 for false that equivalent to mysql enum value 0
}
edit:
one way is that just keep you mysql enum as it is like
`reconciled` enum('true','false') not null default 'false',
and keep your class property datatype to string
public string reconciled { get; set; }
and keep your c# enum with respect to mysql enum
public enum bankaccountreconciled
{
[display(name = "true")]
true,
[display(name = "false")]
false
}
and now just add one more property to your class object that can cast your string
to enum
like
public bankaccountreconciled enumreconciled
{
get
{
return getenumvalue<bankaccountreconciled>(reconciled);
}
}
and above property need a helper function that can convert your string to enum
public static t getenumvalue<t>(string str) where t : struct, iconvertible
{
type enumtype = typeof(t);
if (!enumtype.isenum)
{
throw new exception("t must be an enumeration type.");
}
t val;
return enum.tryparse<t>(str, true, out val) ? val : default(t);
}
output: (from debugger)
score:0
the orders
column is marked as null
on the database, but not as a nullable type in .net (property orders
).
Source: stackoverflow.com
Related Query
- Input string was not in correct format error in LINQ to Excel query
- Linq Error Input string was not in a correct format. System.Exception {System.FormatException}
- Linq Input string was not in a correct format in MVC
- Input string was not in a correct format error, but still able to get parsed value from LINQ to XML query
- Linq error "Input string was not in a correct format."
- Input string was not in the correct format C# ASP.NET
- Input string was not in a correct format
- Input string for parsing CSV file not in correct format
- Input string was not in a correct format in Entity Framework
- "Input string was not in a correct format" when using LINQ
- C# Linq .Select(int.parse) on empty array results in "Input string was not in a correct format"
- linq string datetime ,between and string format exception error
- Int.Parse(String.Split()) returns "Input string was not in a correct format" error
- Paging Error :The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'
- linq - how do you do a query for items in one query source that are not in another one?
- Exception in System.Data.Entity.dll but was not handled in user code
- Linq "Sequence operators not supported for type" Exception
- Why is there an input string exception for a query without where clause?
- An exception of type 'System.ArgumentException' occurred in EntityFramework.dll but was not handled in user code
- Getting "Could not find an implementation of the query pattern for source type 'ExcelQueryable<T>'. " Error
- Linq - Correct format for Left Join
- Linq to EF system not supported exception System.NotSupportedException
- LINQ entity data model generated code error - The type 'DBContexts.Category' already contains a definition for 'ID'
- Linq to EF Search for a string that does not start with a Letter
- source code for LINQ 101 samples
- string format error when reading CSVs to object with LINQ
- uint.Parse on a valid string throws System.FormatException: 'Input string was not in a correct format.'
- Linq Entity Exception not printing error
- Specific linq exception when converting string to int. LINQ to Entities does not recognize the method 'Int32 ToInt32(System.Object)' m
- C# LINQ code not working for XML parse
More Query from same tag
- Using XQuery in Linq To SQL?
- GroupBy with a known class as the grouping key
- Complex Linq query errors "..Entities does not recognize the method.."
- linq multiple order DESCENDING
- Is it better to store query results in memory, or run the same query multiple times?
- Why does this linq projection not work?
- "ADD" to DataGridView from XML file
- NameSpace Manager or XsltContent to parse aspx page
- Unable to cast object of type 'System.DateTime' to type 'System.String'” error
- how to change sql query in example?
- How does EF create the SQL needed to update one million rows in a SQLite table with five million rows? Does it do one by one row updates?
- C# - LINQ Select() calls function twice
- Can this SQL be translated to LINQ?
- Modeling XML Data for a C# Application
- How to return two types of objects in an ASP.net MVC view
- Linq nested Where() clause
- predicate builder c# confusion
- LINQ to SQL LEFT JOIN, GROUP BY, COUNT, MAX and subquery
- How can I merge time entries into a single row for a weekly report?
- Left Join in LINQ Query and ToList
- Guid.ToString() in Linq query?
- Sublists of consecutive elements that fit a condition in a list c# linq
- Compare keys of dictionary with values of List and return all the matching values including duplicates
- Why does Linq need a setter for a 'read-only' object property?
- Order by a field (int). If the field it is not int?
- Dynamically access table in EF Core 2.0
- How to build Expression<Func<T,bool>> from Expression<Func<T>>
- Linq: Explicit construction of entity type in query is not allowed
- MongoDB random results in C# LINQ
- VB.net, How to Combine or Joining Nearest Similar Items in List of String