Silverlight -RIA 服务 - 此 EntitySet 类型为 <>不支持“添加”手术

发布于 2024-08-24 19:07:06 字数 1226 浏览 1 评论 0 原文

在 Silverlight 项目中,当我尝试在单击按钮时将新对象添加到 DataGrid 时,出现此异常。 在 DomainService 类中.. 我知道我必须为要放置的新实体实现添加操作,但我该怎么做呢? 我的意思是我做了类、get 方法,但是如何执行插入操作,我在 this.ObjectContext 中看不到我的类,所以我要向谁添加这个新对象,我有以下代码片段:

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();
        }

请帮助!

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!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

趁年轻赶紧闹 2024-08-31 19:07:07

正确,您不会看到 this.ObjectContext.AddToSisPer。但是您的 ObjectContext 公开了 EntitySet SisPers。每当您调用 ObjectSet.Sispers.Add(SisPer sisper) 时,只要您遵循 域服务。例如,在插入操作中添加 Insert-、Add- 或 Create 前缀,用 [Insert] 属性对其进行修饰,传入 SisPer 实体,然后返回 void。

Correct, you won't see this.ObjectContext.AddToSisPer. But your ObjectContext exposes EntitySet<SisPer> SisPers. Whenever you call ObjectSet.Sispers.Add(SisPer sisper), your insert operation will be called automatically provided you follow the conventions described in Domain Services. E.g. prefix your insert operation with Insert-, Add-, or Create, decorate it with the [Insert] attribute, pass in a SisPer entity, and return void.

歌入人心 2024-08-31 19:07:06

您将需要查看演示模型。合并这两个表有充分的理由吗?它增加了很多工作,您只需公开两个表就可以避免这些工作。如果您不希望某些属性在客户端上可用,您可以对它们使用 ExcludeAttribute。

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文