Can I add custom read-only property to entity class? RRS feed

  • Question



    I have entity class called User and I manually added read-only property

    public bool IsAdmin
      ...check to see if this user is admin

    When I retrieve user as below,  InvalidOperationException thrown saying that "Cannot assign value to member 'IsAdmin'. It does not define a setter."

    IMultipleResults results = ...
    var values =  results.GetResult<User>();

    Can't I add custom properties to generated class?

    Saturday, February 23, 2008 4:41 PM


All replies

  • In part 1 of my series of articles about LINQ to SQL I describe how to create and use non-mapped properties in the partial entity classes :

    Saturday, February 23, 2008 6:19 PM
  • Hi!

    i'm trying to do these same custom properties, but with Linq queries.

    public int ChildCount
                     return this.tbChild.Where(c=>c.IdFather == this.Id).Count();

    it's very slowly!!
    Any ideias?

    Thanks so much!!

    Sunday, June 14, 2009 4:57 AM