【发布时间】:2014-05-28 07:27:20
【问题描述】:
我正在构建招标板
这里是描述: 在我的简单会员角色表中,我有: (管理员、投标人、提供商、会员)
管理:他有权将普通用户角色从“会员”更改为“供应商并在招标组织批准后证明中标者。
供应商:普通用户将被指定为“会员”,并由管理部门激活为供应商,然后他们可以投标任何他们想要的项目。
项目:由招标组织用户创建每个项目都有许多要求
要求:每一项都与项目相关。
招标:这里我的问题实际上是招标是“国家的部委,必须在系统中设置”,但每个部委显然都有很多用户“经理,每个人说 5 个”谁会投票供应商。经理只能投票给同一部门下的供应商。
我想念其他桌子吗?
另外我真的不知道如何用关系和(UserprofileTbale 和 Role Table)来构造所有表: 这是我的尝试,请帮助我。
我的 DBContext:
public class ProjectContext : DbContext
{
public ProjectContext()
: base("OTMSProjects")
{
}
public DbSet<ProjectEntry> Entries { get; set; }
public DbSet<Requiernments> RequiernmentEntries { get; set; }
public DbSet<Supplier> Suppliers { get; set; }
public DbSet<Tender> Tenders { get; set; }
public DbSet<UserProfile> UserProfiles { get; set; }
//public DbSet<UserRoles> UserRoles { get; set; } // do I have to set this too?
}}
我的桌子:
public class ProjectEntry
{
[Key]
public int ID { get; set; }
[Required]
public string ProjectName { get; set; }
public string Description { get; set; }
public string Statue {get; set; }
public string UplodedFiles { get; set; }
public string Budget { get; set; }
public string EstimateTime { get; set; }
public string Criterias { get; set; }
public DateTime? DueDate { get; set; }
// Relations with others tables
public virtual Tender Tender { get; set; }// every project have only one tender
public virtual ICollection<Supplier> Suppliers { get; set; } // every project have one or more supplier
public virtual ICollection<Requiernments> Requirements { get; set; }
}
........
public class Requiernments
{
[Key]
public int RequiernmentId { get; set; }
public int ID { get; set; }
public string RequiernmentName { get; set; }
public string RequiernmentType { get; set; }
public string RequiernmentPrioritet { get; set; }
public float RequiernmenWhight { get; set; }
public string ProviderAnswer { get; set; }
public string ProviderComments{ get; set; }
public virtual ProjectEntry Projects { get; set; }
}
........
public class Supplier
{
[Key]
public int SupplierId { get; set; }
public int ID { get; set; }
public int SupplierName { get; set; }
public int SupplierCat { get; set; }
public virtual ICollection<ProjectEntry> Projects { get; set; }
}
......
public class Tender
{
[Key]
public int TenderId { get; set; }
public string TenderName { get; set; }
public string TenderMinstry{ get; set; }
public int ID { get; set; }//link to project
public int UserId { get; set; } //this links to the userid in the UserProfiles table
public virtual ICollection<ProjectEntry> Projects { get; set; }
//public virtual ICollection<UserProfile> Userprofile { get; set; }
public virtual UserProfile UserProfile { get; set; }
}
我的 AccountModel 中的成员资格表由 Mvc4 中的默认创建(我只添加 RoleTable :
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
public string EmailAddress { get; set; }
public ICollection<UserRoles> UserRoles { get; set; }
}
[Table("webpages_Roles")]
public class UserRoles
{
[Key]
public int RoleId { get; set; }
public string RoleName { get; set; }
[ForeignKey("UserId")]
public ICollection<UserProfile> UserProfiles { get; set; }
}
也不确定如何将 Userprofile 与投标表和供应商表链接?
【问题讨论】:
-
“我想念其他桌子吗?”,这是你的问题吗? StackOverflow 不适合解决设计问题。
-
不行,我需要检查表(一对多)和(多对多)之间的关系
标签: c# entity-framework asp.net-mvc-4 model