EF外键添加

关于外键添加,直接使用赋值的方式。

public partial class YXTDemand : FullAuditedEntity<int, User>
{
    public virtual YXTOrigin Origin { get; set; }   
}
public partial class YXTOrigin : FullAuditedEntity<int, User>
{
    public virtual ICollection<YXTDemand> YXTDemands { get; set; }
}
View Code

 

var entity= var entity = input.MapTo<YXTDemand>();
var merchandise = await _yXTMerchandiseRepository.GetAsync(Merchandise_Id);
entity.SpecifiedOrigin = origin.OriginName;
await _yXTDemandRepository.InsertAsync(entity);
View Code

 

posted on 2017-11-06 17:00  阿鄙  阅读(296)  评论(0编辑  收藏  举报