asp.net – Orchard CMS 1.x [文档存储] – 混合记录支持和记录
发布时间:2020-12-16 09:53:51 所属栏目:asp.Net 来源:网络整理
导读:我正在关注Bertrand Le Roy的指南,将OrchardCMS迁移到Document Storage(1.x分支预发布) http://weblogs.asp.net/bleroy/archive/2013/11/04/the-shift-how-orchard-painlessly-shifted-to-document-storage-and-how-it-ll-affect-you.aspx 以下是我的示例代
我正在关注Bertrand Le Roy的指南,将OrchardCMS迁移到Document Storage(1.x分支预发布)
http://weblogs.asp.net/bleroy/archive/2013/11/04/the-shift-how-orchard-painlessly-shifted-to-document-storage-and-how-it-ll-affect-you.aspx 以下是我的示例代码中的一些摘录,旨在将记录支持和无记录属性混合到ContentPart中. 移民 public int Create() { SchemaBuilder.CreateTable("CustomerPartRecord",table => table .ContentPartRecord() .Column<string>("Name") ); ContentDefinitionManager.AlterPartDefinition("CustomerPart",builder => builder .Attachable()); ContentDefinitionManager.AlterTypeDefinition("Customer",type => type .WithPart("CommonPart") .WithPart("Title") .WithPart("CustomerPart") .Creatable()); return 1; } ContentPartRecord public class CustomerPartRecord : ContentPartRecord { public virtual string Name { get; set; } public virtual string Phone { get; set; } public virtual string Email { get; set; } } ContentPart public class CustomerPart : ContentPart<CustomerPartRecord> { public string Name { get { return Record.Name; } // tried "return Retrieve(x=>x.Name);" set { Record.Name = value; } // tried "return Store(x=>x.Name,value);" } public string Phone { get { return this.Retrieve(x => x.Phone); } //Recordless property set { this.Store(x => x.Phone,value); } } public string Email { get { return this.Retrieve(x => x.Email); } //Recordless property set { this.Store(x => x.Email,value); } } } 尝试添加新记录时引发以下错误 could not insert: [Customers.Models.CustomerPartRecord#28][SQL: INSERT INTO Teknorix_Customers_CustomerPartRecord (Name,Phone,Email,Id) VALUES (?,?,?)] ---> System.Data.SqlServerCe.SqlCeException: The column name is not valid. [ Node name (if any) =,Column name = Phone ] 如果我添加手机和电话,这绝对可以. DB中的电子邮件列.但随后它将数据写入2个位置.在xml中,它只会插入手机和电子邮件字段.在表格中,它将插入整个记录. 我知道如果我使用Retrieve()代替this.Retrieve()然后它会将整个记录存储在两个地方等等…… 但我感兴趣的是只在XML信息集中只有一些字段,而在记录表中只有一些字段.我在这做错了什么? 解决方法
如果您的部件有记录,您仍然可以仅在信息集中定位属性,而不需要存在记录属性.为此,请使用此功能获取信息集.如< InfosetPart>().然后,使用InfosetHelper中的扩展方法,例如infosetPart.Retrieve< string>(“Phone”)和infosetPart.Store< string>(“Phone”,value).
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 为什么默认情况下GET请求返回JSON不允许?
- asp.net-mvc – Azure托管的ASP.NET MVC网站删除与客户端缓
- msbuild – 为什么aspnet_compiler需要对构建服务器上的Tem
- asp.net-mvc – HtmlHelper与Partial的表现
- asp.net-mvc – 使用ServiceStack设计Web应用程序
- asp.net-mvc – ASP.NET MVC内联Razor变量
- .net – SqlBulkCopy超时
- asp.net – 检查site.master页面中的条件
- 为什么在ASP.NET Web API中从请求中删除内容范围标题?
- asp.net-mvc-3 – MVC3强制验证隐藏字段
推荐文章
站长推荐
- 如何更改asp.net identity 3(vnext)使用的表名?
- 从未调用ASP.NET Web API自定义JsonConverter
- asp.net-mvc – RavenDB部署问题
- asp.net – HTTP错误500.23之后添加到我的本地网
- asp.net-mvc-3 – 在MVC3中,如何获取当前控制器名
- asp.net – 是否可以在ApplicationServices DB中
- asp.net – MVC5发布到Azure,因为云服务在AD登录
- 如何设置特定于ASP.NET请求的log4net上下文属性?
- wcf – SOAP API HTTPS – 与经典ASP连接
- asp.net-mvc-3 – 使用多个Web应用程序共享控制器
热点阅读