Asp.net mvc 3 如何在Orchard CMS中存储逗号分隔的列表?

Asp.net mvc 3 如何在Orchard CMS中存储逗号分隔的列表?,asp.net-mvc-3,orchardcms,Asp.net Mvc 3,Orchardcms,使用Orchard CMS,我正在处理一个记录和一个部分代理,但我不知道如何将其保存到数据库中。事实上,我承认我甚至不知道如何将我试图保存的项目保存到这个范例中。我最初使用enum进行选择: MyEmum.cs: public enum Choices { Choice1, Choice2, Choice3, Choice4 } public virtual string MyProperty { get; set; } public IEnumerable<string> My

使用Orchard CMS,我正在处理一个记录和一个部分代理,但我不知道如何将其保存到数据库中。事实上,我承认我甚至不知道如何将我试图保存的项目保存到这个范例中。我最初使用
enum
进行选择:

MyEmum.cs

public enum Choices { Choice1, Choice2, Choice3, Choice4 }
public virtual string MyProperty { get; set; }
public IEnumerable<string> MyProperty
{
    get
    {
        if (String.IsNullOrWhiteSpace(Record.MyProperty)) return new string[] { };
        return Record
            .MyProperty
            .Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries)
            .Select(r => r.Trim())
            .Where(r => !String.IsNullOrEmpty(r));
    }
    set { Record.MyProperty = value == null ? null : String.Join(",", value); }
}
MyRecord.cs

public enum Choices { Choice1, Choice2, Choice3, Choice4 }
public virtual string MyProperty { get; set; }
public IEnumerable<string> MyProperty
{
    get
    {
        if (String.IsNullOrWhiteSpace(Record.MyProperty)) return new string[] { };
        return Record
            .MyProperty
            .Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries)
            .Select(r => r.Trim())
            .Where(r => !String.IsNullOrEmpty(r));
    }
    set { Record.MyProperty = value == null ? null : String.Join(",", value); }
}
MyPart.cs

public enum Choices { Choice1, Choice2, Choice3, Choice4 }
public virtual string MyProperty { get; set; }
public IEnumerable<string> MyProperty
{
    get
    {
        if (String.IsNullOrWhiteSpace(Record.MyProperty)) return new string[] { };
        return Record
            .MyProperty
            .Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries)
            .Select(r => r.Trim())
            .Where(r => !String.IsNullOrEmpty(r));
    }
    set { Record.MyProperty = value == null ? null : String.Join(",", value); }
}
public IEnumerable MyProperty
{
得到
{
if(String.IsNullOrWhiteSpace(Record.MyProperty))返回新字符串[]{};
返回记录
.我的财产
.Split(新[]{.'},StringSplitOptions.RemoveEmptyEntries)
.Select(r=>r.Trim())
.Where(r=>!String.IsNullOrEmpty(r));
}
set{Record.MyProperty=value==null?null:String.Join(“,”,value);}
}
现在,在我的服务课上,我尝试了以下方法:

public MyPart Create(MyPartRecord record)
{
    MyPart part = Services.ContentManager.Create<MyPart>("My");
    ...
    part.MyProperty = record.MyProperty; //getting error here
    ...
    return part;
}
公共MyPart创建(MyPartRecord)
{
MyPart=Services.ContentManager.Create(“我的”);
...
part.MyProperty=record.MyProperty;//此处获取错误
...
返回部分;
}
但是,我遇到以下错误:
无法将'string'隐式转换为System.Collections.Generic.IEnumerable'

本质上,我试图将复选框列表中的选项(一个或多个选项)保存为数据库中以逗号分隔的列表

这甚至不能解决如何使用
enum
的问题。有什么想法吗

对于某些背景:

我知道处理这种关系的适当方法是创建一个单独的表并使用
IList
。但是,这是一个简单的列表,我不打算对其进行编辑(事实上,在这个场景中没有使用驱动程序,因为我使用控制器和路由在前端处理它)。我只是为了统计/历史目的而捕获数据并在管理视图中重新显示它。我甚至可以考虑去掉部分(考虑下面的帖子:

< P>):

part.MyProperty = new[] {"foo", "bar"};
例如,部件的setter将把记录属性上的值存储为逗号分隔的字符串,该字符串将被持久化到数据库中

如果要使用枚举值,应该使用.NET在枚举上提供的
Parse
ToString
API