none
Linq Error/error using class method RRS feed

All replies

  • Hello,

    >>Linq.IOrderedQueryAble does not contain a definition for 'CompletionTime' and no Extension method 'CompletionTime' accepting a first argument of type 'System.Linq.IOrderedQueryable.

    foreach(var subResult in data.Status.Select(x => x.ID).Distinct().Select(Id => data.Status.Where(x => x.ID == Id).OrderBy(x => x.Time)))

    The subResult actually is an object of Status entity class rather Result entity class, since I do not know how the Status entity class is defined, I guess it does not have a CompletioTime property, so it will throw an error message.

    If we want to return the Result type, then we should query the collection of Result type rather Status like below:

    foreach (var subResult in db.Results.Select(result => result))

    Or you can share the definition of the Status entity class and the association between Status and Result and what you want to do with the query so that we can help you better.

    If I misunderstand, please let me know.

    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.

    Monday, December 30, 2013 3:18 AM
    Moderator
  • Hello CatLikeOlive0,

    I think you should need to know more about LINQ Query and how it works with foreach.

    Please refer to link below:

    http://msdn.microsoft.com/en-us/library/bb397906.aspx


    Tuesday, December 31, 2013 8:36 AM
  • Hello CatLikeOlive0,

    Is it that you want to find out Result record whose Id is existing in Status table by the Id field?

    If it is, then I suggest writing the query outside of the foreach block and using the join as below:

     var result= from result in db.Result
                    join status in db.Status on result.Id equal status.Id
                    order by status.Time
                    select result;
        foreach (var subResult inresult)
        {
            //...
            }

    For join clause, please refer to link:http://msdn.microsoft.com/en-us/library/bb311040.aspx

    For order by clause, please refer to link:http://msdn.microsoft.com/en-us/library/bb882684.aspx

    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.

    Wednesday, January 1, 2014 5:52 AM
    Moderator