从相关对象创建新的实体框架记录

时间:2019-07-25 19:21:14

标签: entity-framework

创建实体框架对象时是否可以使用SetValues()。

我有一个与实体框架类具有相同字段定义的类,并找到了这种解释,它说明了使用SetValues函数更新ef记录的更简便方法。

https://researchaholic.com/2013/02/06/entity-framework-5-easier-way-to-update-record/

我的问题是:是否有一种类似的方法来创建新的ef记录,而无需指定这样的每个字段:

var newItm = new Import.EntityClasses.ImportSiteList {
    SiteId = ssItm.SiteId,
    OrganizationId = ssItm.OrganizationId,
    TimeZoneId = ssItm.TimeZoneId
};
tbl.Add(newItm);

1 个答案:

答案 0 :(得分:0)

这是您可以做的

.card {
  position: relative; /** allow the ".overlay" to be positionned relative to ".card" **/
  margin: 15px 0;
}

/** the ".card" having some scrolling **/
.card.has-height {
  height: 180vh; /** just to have some scrolling, remove this or replace it with your desired value **/
}

.overlay {
  display: flex; /** to center the checkmark both vertically and horizontally with two simple rules **/
  position: absolute; 
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  justify-content: center; /** center the checkmark horizontally **/
  align-items: center; /** center the checkmark vertically **/
  background-color: rgba(24, 24, 24, .6); /** transparent black background to see the effect when scrolling **/
}

/** some styling for the checkmark **/
.overlay .fa {
  font-size: 1.5rem;
  font-weight: bold;
}

希望有帮助。