代表IList实体框架 4.0 中的属性

发布于 2024-10-26 07:08:54 字数 636 浏览 3 评论 0原文

我们定义了一个模型类,我想从 EF 4.0 edmx 生成该模型类以实现持久性。该类大致如下:

    [DataContract]
public class Schedule
{
    [DataMember]
    public string Name { get; set; }

    [DataMember]
    public Guid Id { get; set; }

    [DataMember]
    public DateTime RunDate { get; set; }

    [DataMember]
    public IList<Guid> Routes { get; set; }
    [DataMember]
    public IList<Guid> Paths { get; set; }
}

如何在 edmx 设计界面上表示路由和路径?除了使用单个 Guid Id 字段创建两个实体然后设置 1-* 与 Schedule 的关联之外,我看不到其他任何方法。我宁愿不必这样做,因为我们将拥有一个 Route 和 Path 类,但这不是我们目前想要的。

我们还没有机会了解 Code First,也没有时间为这个项目弄清楚它,但它能支持我们的需求吗?

感谢您的任何帮助。

We have a model class defined that I want to produce from our EF 4.0 edmx for persistence. The class looks roughly as follows:

    [DataContract]
public class Schedule
{
    [DataMember]
    public string Name { get; set; }

    [DataMember]
    public Guid Id { get; set; }

    [DataMember]
    public DateTime RunDate { get; set; }

    [DataMember]
    public IList<Guid> Routes { get; set; }
    [DataMember]
    public IList<Guid> Paths { get; set; }
}

How do I represent Routes and Paths on the edmx design surface? I can't see anyway of doing this other than creating two entities with a single Guid Id field then setting a 1-* Association to Schedule. I'd rather not have to do that as we'll then have a Route and Path class that isn't what we want at the moment.

We haven't had chance to look at Code First yet and don't really have time to figure it out for this project but would it support our needs?

Thanks for any assistance.

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

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

发布评论

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

评论(1

顾挽 2024-11-02 07:08:54

您必须使用相关实体,或者不能直接映射它们。例如,您可以映射另一个名为 RoutesSerializedPathsSerialized 的字段,它们的类型为字符串,包含所有存储为字符串并用分号分隔的 Guid。您当前的属性将使用 return IEnumerable 并使用内部使用的函数,例如 String.JoinString.SplitToString和Guid.Parse。

You must either use related entities or you musn't map them directly. You can for example map another fields called RoutesSerialized and PathsSerialized which will be of type string and contains all Guids stored as strings and separated by semicolon. Your current properties will use return IEnumerable and use internally use functions like String.Join, String.Split, ToString and Guid.Parse.

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