如何让RIA在生成实体时忽略属性?
背景:Silverlight 4(“Library”silverlight 项目)连接到实体框架模型(Library.Web Web 应用程序项目)的 RIA。
描述:
我有一个类:
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; }
}
当我尝试编译时,RIA 生成以下错误:
实体“MyCompany.Library.Book”有一个属性“Info”,其 不支持的类型。
问题: 我在 SL4 应用程序中不需要该属性,所以我想知道如何防止 RIA 在生成代理对象时尝试生成该属性?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用属性 [排除] ria 不会将该属性传递给客户端,它仅在服务器端可见,我认为这就是您正在寻找的:D
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
发生错误是因为我的属性需要一个默认构造函数。在您的情况下,您可能需要 BookInfo 的默认构造函数
My error occurred because I needed a default constructor for my property. In your case it maybe that you need a default constructor for BookInfo