实体框架CF模型结构

时间:2013-10-08 17:33:58

标签: c# asp.net asp.net-mvc entity-framework

我已经在这方面工作了一段时间,但我仍然没有想出一个好主意。

我有3种ProjectUserResult。用户和项目可以有多个结果。我现在的问题是结果可以是多种类型(现在12种,可以改变)。我不知道我应该如何构建这个结果,这个结果的共同点是一个类型和一个Id,我想为每个不同的12种类型提供一个表。

所以我到现在所拥有的就是这个。

项目

public class Project :ITypedEntity<ProjectType>
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Nationality { get; set; }
    public virtual ProjectType Type { get; set; }
    public string TitleEn { get; set; }
    public string TitleRo { get; set; }
    public string Acronym { get; set; }
    public string ContractNo { get; set; }
    public virtual ActivityField ActivityField {get;set;}
    public string SummaryEn { get; set; }
    public string SumarryRo { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
    public decimal Value { get; set; }
    public bool IsPartner { get; set; }
    public ICollection<User> Team{get;set;}
    public string Website {get;set;}
    public ICollection<INamedEntity> Results;
}

结果

public class Result:ITypedEntity<ResultType>
    {
        public int Id { get; set; }
        public string Name{get;set;}
        public ResultType Type { get; set; }
    }

用户

public class User:Person
    {
        public int CNP { get; set; }
        public virtual Faculty Faculty { get; set; }
        public bool IsUSAMV {get;set;}
        public virtual ICollection<INamedEntity> Results {get;set;}
        public virtual ICollection<Project> Projects {get;set;}
    }

我认为这不会有帮助,但无论如何我都会粘贴它们

public interface INamedEntity:IEntity
{
    string Name{get;set;}
}
public interface ITypedEntity<TType>:INamedEntity{
    TType Type { get; set; }
}
public interface IEntity
{
    int Id { get; set; }
}

更新1 一些结果类型

public class BookChapter:INamedEntity
{
    public int Id { get; set; }
    public string Name { get; set; }
    public virtual Book Book {get;set;}
    public int PagesInChapter {get;set;}
    public string Pagination {get;set;}
}


public class Book:INamedEntity
{
    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection<Person> Authors { get; set; }
    public int Year { get; set; }
    public Publisher Publisher {get;set;}
    public int NumberOfPages { get; set; }
    public string Pagination { get; set; }
    public int ISBN { get; set; }
}


public class Patent:ITypedEntity<PatentType>
{
    public int Id { get; set; }
    public string Name { get; set; }
    public virtual ICollection<Person> Authors { get; set; }
    public virtual Person Holder{get;set;}
    public string Number{get;set;}
    public virtual PatentType Type { get; set; }
}

很抱歉,如果问题不明确,我会用您需要的任何其他信息进行更新。 感谢。

0 个答案:

没有答案