【发布时间】:2014-09-05 17:06:09
【问题描述】:
我正在尝试为网站设置创建一个白名单部分,以允许管理员用户输入被视为“白名单”的 url 列表。不过,我在将这些信息存储在数据库中时遇到了问题。当使用属于数据库的信息创建新的内容类型时,您可以使用以下内容:
public class ShareBarSettingsPart : ContentPart<ShareBarSettingsPartRecord> {
public string AddThisAccount {
get { return Record.AddThisAccount; }
set { Record.AddThisAccount = value; }
}
}
在数据库中设置 AddThisAccount 的值。我的问题是我需要数据库中的 url 列表,而不仅仅是单个项目。我尝试了以下方法,但它给了我一个错误:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;
namespace Speedbump.Models
{
public class SpeedBumpSettingsRecord : ContentPartRecord
{
public virtual List<string> whiteList { get; set; }
}
public class SpeedBumpSettingsPart : ContentPart<SpeedBumpSettingsRecord>
{
public List<string> whiteList
{
get { return Record.whiteList; }
set { Record.whiteList.Add(value); } //I need to be able to add a single record to the list here
}
}
}
任何帮助将不胜感激,谢谢。
【问题讨论】:
标签: database list settings orchardcms record