The type of one of the primary key values did not match the type defined in the entity. See inner exception for details

后端 未结 4 1421
轻奢々
轻奢々 2021-01-12 09:41

I have the followng method:-

public ActionResult CustomersDetails(string[] SelectRight)
{
    var selectedCustomers = new SelectedCustomers
    {
        Inf         


        
4条回答
  •  孤独总比滥情好
    2021-01-12 09:58

    Look at the exception message The argument types 'Edm.Int64' and 'Edm.String' are incompatible for this operation. Near WHERE predicate, line 1, column 90..

    This implies that the ID of your AccountDefinition class is a long or Int64 however you are trying to query it using a string.

    You need to do one of the following:

    1. Change string[] in CustomersDetails(string[] SelectRight) to long[] and string in GetAccount(string id) to long id
    2. Change return entities.AccountDefinition.Find(id); to return entities.AccountDefinition.Find(long.Parse(id));

    Option 1 is the better option but will require more change (which I would recommend you do), Option 2 is less change but has the possibility it will blow up if id is null or a value which cannot be parsed to a long.

提交回复
热议问题