-1
一对多的关系我有两个表:一个在EF代码首先
用户
ID
Username
Password
内容
Id
Caption
Content
Description
insertUserId
editUserId // Allow null
deleteUserId //Allow null
我如何用流利的API插件模型和配置?
一对多的关系我有两个表:一个在EF代码首先
用户
ID
Username
Password
内容
Id
Caption
Content
Description
insertUserId
editUserId // Allow null
deleteUserId //Allow null
我如何用流利的API插件模型和配置?
没有答案?
这是我的原单类:
PAGE_CLASS
public class Page
{
internal class Configuration : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Page>
{
public Configuration()
{
HasRequired(current => current.ApplicationInsUser)
.WithMany(user => user.InsertedPages)
.HasForeignKey(current => current.ApplicationInsUserId)
.WillCascadeOnDelete(false);
HasOptional(current => current.ApplicationEditUser)
.WithMany(user => user.EditedPages)
.HasForeignKey(current => current.ApplicationEditUserId)
.WillCascadeOnDelete(false);
}
}
public Page()
{
}
[Key]
public int id { get; set; }
[MaxLength(50, ErrorMessage = "حداکثر طول 50 کاراکتر می باشد")]
public string Onvan { get; set; }
[System.Web.Mvc.AllowHtml]
public string Content { get; set; }
[MaxLength(50, ErrorMessage = "حداکثر طول 50 کاراکتر می باشد")]
public string EngOnvan { get; set; }
[MaxLength(150, ErrorMessage = "حداکثر طول 50 کاراکتر می باشد")]
public string Description { get; set; }
[MaxLength(150, ErrorMessage = "حداکثر طول 50 کاراکتر می باشد")]
public string Keyword { get; set; }
public DateTime CreateTime { get; set; }
public DateTime? ExpTime { get; set; }
public Boolean? Enable { get; set; }
public Boolean? Delete { get; set; }
public string ApplicationInsUserId { get; set; }
public virtual ApplicationUser ApplicationInsUser { get; set; }
public string ApplicationEditUserId { get; set; }
public virtual ApplicationUser ApplicationEditUser { get; set; }
}
,这是身份模型:
IdentityModel
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
//Custom User Properties
public virtual IList<Page> InsertedPages { get; set; }
public virtual IList<Page> EditedPages { get; set; }
}
等都不是代码编写Servi大街我们不会为你做你的工作。另请阅读[我如何提出一个好问题](http://stackoverflow.com/help/how-to-ask)。请包括一个[最小化,完整和可验证的示例](http://stackoverflow.com/help/mcve),当您遇到问题时运行。 – Igor
https://www.youtube.com/watch?v=VAtVv1Q7ufM – nurdyguy