none
An error occurred while executing the command definition - LINQ RRS feed

  • Question

  • I am getting this exception
    at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
    at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
    at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
    at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
    at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)

    When i execute this code

    var entity = context.TableWith2MillionRecords.FirstOrDefault(s => s.CountryId == countryId && (s.ISO2.ToUpper().Contains(stateDescr.ToUpper()) || s.Region1.ToUpper().Equals(stateDescr)));

    What is the cause?

    Thanks


    muzammil ahmed

    • Moved by Caillen Thursday, October 31, 2013 8:26 AM Linq and EF question.
    Tuesday, October 29, 2013 11:31 PM

Answers

  • Hello,

    It is appreciated that if you can share the table structure and the environment.

    With the codes, I made a sample and it worked fine. Please have a look at the sample below:

    using (DataBaseFirstDBEntities db = new DataBaseFirstDBEntities())
    
                {
    
                    var orderdetail = db.OrderDetails.FirstOrDefault(od => od.OrderID == 2 && (od.OrderDetailCode.ToUpper().Contains("O")||od.OrderDetailName.ToUpper().Equals("3ooo")));
    
                }
    

    The result:

    I use VS2012, .Net Frameowork 4.5, Entity Framework 5, Win8(64Bit).

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 1, 2013 6:47 AM
    Moderator

All replies

  • You seem to have an EF issue,  and you should post to the EF forum. 

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework

    Wednesday, October 30, 2013 1:26 AM
  • Hello,

    It is appreciated that if you can share the table structure and the environment.

    With the codes, I made a sample and it worked fine. Please have a look at the sample below:

    using (DataBaseFirstDBEntities db = new DataBaseFirstDBEntities())
    
                {
    
                    var orderdetail = db.OrderDetails.FirstOrDefault(od => od.OrderID == 2 && (od.OrderDetailCode.ToUpper().Contains("O")||od.OrderDetailName.ToUpper().Equals("3ooo")));
    
                }
    

    The result:

    I use VS2012, .Net Frameowork 4.5, Entity Framework 5, Win8(64Bit).

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 1, 2013 6:47 AM
    Moderator