views:

486

answers:

1

In Silverlight project I have this exception when I tried to Add a new object to a DataGrid when a button is clicked. In the DomainService class.. I know I have to implement the Add operation for the new Entity I'm putting, but how can I do that? I mean I did the class, the get method but how do I do the insert operation, I can't see my class in this.ObjectContext, so to whom I would be adding this new object, I have the next fragments of code:

public partial class SisPer
    {
        [Key]
        public int Id { get; set; }
        public string Nombre_Sistema { get; set; }
        public string Nombre_Perfil { get; set; }
        public string Nivel { get; set; }
        public bool Estatus { get; set; }
    }

 public IQueryable<SisPer> Get_SisPer()
        {

            var query =
                   from per in this.ObjectContext.Cat_Perfil
                   join sis in this.ObjectContext.Cat_Sistema
                   on per.Cat_Sistema.Id equals sis.Id

                   select new SisPer()
                   {
                       Id = per.Id,
                       Nombre_Sistema = sis.Nombre,
                       Nombre_Perfil = per.Nombre,
                       Nivel = per.Nivel,
                       Estatus = per.Estatus
                   };

        return query;
    }
public void InsertSisPer(SisPer sisper)
        {
          ?? I can't see this.ObjectContext.AddToSisPer();
        }

Plz Help!!

A: 

You will want to check out the presentation model. Is there a good reason to combine the two tables? It adds a lot of work that you could avoid by just exposing both tables. If you don't want some of the properties to be available on the client you can use the ExcludeAttribute on them.

http://blogs.msdn.com/deepm/archive/2009/11/20/wcf-ria-services-presentation-model-explained.aspx

JosephC