/// <summary> /// 更新实体对象 /// </summary> /// <param name="item">实体对象</param> public void UpdateRow(EntityInfoWithAttrValueListItem item) { var session = SessionFactory.CreateSession(); try { session.BeginTrans(); //更新主表记录 var entityInfo = QuickRepository.GetById <EntityInfoEntity>(item.EntityInfo.ID); entityInfo.LastUpdatedDatetime = System.DateTime.Now; entityInfo.LastUpdatedUserID = item.EntityInfo.LastUpdatedUserID; entityInfo.LastUpdatedUserName = item.EntityInfo.LastUpdatedUserName; QuickRepository.Update <EntityInfoEntity>(session.Connection, entityInfo, session.Transaction); //更新扩展属性表记录 var eavManager = new EntityAttrValueManager(); eavManager.UpdateItem(session.Connection, item.EntityAttrValueList, session.Transaction); session.Commit(); } catch (System.Exception ex) { session.Rollback(); throw; } finally { session.Dispose(); } }
public void InsertRowFlow(EntityAttrValueFlowItem item) { //首先保存表单数据 int newEntityInfoID = 0; var session = SessionFactory.CreateSession(); try { session.BeginTrans(); //保存实体基本信息 var entityInfo = item.EntityInfo; entityInfo.CreatedDatetime = System.DateTime.Now; entityInfo.LastUpdatedDatetime = System.DateTime.Now; newEntityInfoID = QuickRepository.Insert <EntityInfoEntity>(session.Connection, entityInfo, session.Transaction); //保存实体扩展属性 foreach (var v in item.EntityAttrValueList) { v.EntityInfoID = newEntityInfoID; } var attrValueList = item.EntityAttrValueList; var eavManager = new EntityAttrValueManager(); eavManager.InsertBatch(session.Connection, attrValueList, session.Transaction); session.Commit(); } catch (System.Exception ex) { session.Rollback(); throw; } finally { session.Dispose(); } //启动流程 }