locked
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
    {
     get{
      ...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

Answers

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
    {
            get
            {
                     return this.tbChild.Where(c=>c.IdFather == this.Id).Count();
            }
    }

    it's very slowly!!
    Any ideias?

    Thanks so much!!

    DanieL!
    Sunday, June 14, 2009 4:57 AM