Customized EF data property throw LINQ to Entities Exception when doing a sort

6 posts, 0 answers
  1. David
    David avatar
    26 posts
    Member since:
    Oct 2010

    Posted 03 Mar 2011 Link to this post

    I have DB table Vehicle and I am using EF4. So I got a partial class Vehicle to map with the db table.
    Vehicle is a master table. It has a detail table Fault.  1 vehicle could have many faults.

    I am trying to get the count of fault associated with vehicle. So I created one customized property for Vehicle class. FaultCount.

    Partial Class Vehicle

        public global::System.Int32 FaultCount
                    CCF20Entities ccf20Ent = new CCF20Entities();
                    return ccf20Ent.Faults.Where(f => f.IsActive && f.FaultType == "Vehcile" && f.VehicleID== this.VehicleID).Count();


    Everything works fine. I got the data I want and populate the grid. But when I try to sort the column, I get the exception.

    "The specified type member 'FaultCount' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported."

    Any help?

  2. Rossen Hristov
    Rossen Hristov avatar
    2477 posts

    Posted 03 Mar 2011 Link to this post

    Hi David,

    Unfortunately, this functionality is not supported by the current version of EF.

    You will have to add this property to the actual data model, i.e. calculate it in the DB, and use it like a "normal" property.

    Best wishes,
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. TDG
    TDG avatar
    8 posts
    Member since:
    Nov 2010

    Posted 14 Nov 2011 Link to this post

    Does this problem supported yet?
    I have many custom properties in many model class.
    How do I use this model class with custom properties with MVC?

  4. Kevin Hendriks
    Kevin Hendriks avatar
    56 posts
    Member since:
    Feb 2009

    Posted 15 Nov 2011 Link to this post

    I just got the same error in my application. I get table of which I need value and then be able to sort/group the data like so:
    public partial class CUSTOMER_ORDER
            public string OrderDescription
                    if (ERPConnectionVisualEnterprise._ErpSystem != null && ERPConnectionVisualEnterprise._ErpSystem.USER_DEF_FIELDs.Any(item => item.DOCUMENT_ID.Equals(this.ID) && item.ID.Equals("UDF-0000030")))
                        return ERPConnectionVisualEnterprise._ErpSystem.USER_DEF_FIELDs.Single(item => item.DOCUMENT_ID.Equals(this.ID) && item.ID.Equals("UDF-0000030")).STRING_VAL;
                    return "";

    I am unable to modify the DB because it is managed by another application/company
  5. Mark
    Mark avatar
    65 posts
    Member since:
    Nov 2009

    Posted 07 Nov 2014 Link to this post

    is this possible yet?
    I am having the same problem.

  6. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 07 Nov 2014 Link to this post


    As it turns out this functionality is still not supported. 

    As per your request, I logged it into our system as a Feature Request. You can vote for it and follow its progress on our feedback portal here:
    Add data operations support for customized EntityFramework data properties. 


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top