Search code examples
c#silverlightpropertiesria

How to make RIA ignore a property when generating entities?


Background: Silverlight 4 ("Library" silverlight project) RIA connected to Entity Framework Model (Library.Web web application project).

Description:

I have a class:

public class Book
{
    [Key]
    public int ID { get; set; }
    public String Name { get; set; }
    public DateTime DatePublished { get; set; }

    // I don't need this one in SL4
    public BookInfo Info { get; set; }
}

When I try to compile, RIA generates the following error:

Entity 'MyCompany.Library.Book' has a property 'Info' with an unsupported type.

Question: I don't need that property in SL4 application so what I want to know is how to prevent the RIA from trying to generate that property when generating the proxy object?


Solution

  • public class Book
    {
        [Key]
        public int ID { get; set; }
        public String Name { get; set; }
        public DateTime DatePublished { get; set; }
    
        // I don't need this one in SL4
        [Exclude]
        public BookInfo Info { get; set; }
    }
    

    Using the Attribute [Exclude] ria wont pass that property to the client side and it will only be visible on the server side i think this is what you are looking for :D