本文整理汇总了C#中Update.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Update.Execute方法的具体用法?C# Update.Execute怎么用?C# Update.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Update
的用法示例。
在下文中一共展示了Update.Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateProjectsInDB
public static void UpdateProjectsInDB(List<ChildProject> cProjects)
{
var userConnection = TerrasoftApi.GetuserConnection();
foreach (var item in cProjects)
{
Update update = new Update(userConnection, "Project")
.Set("StartDate", Column.Const(item.StartDate))
.Set("EndDate", Column.Const(item.EndDate))
.Where("Id").IsEqual(Column.Const(item.ChildId)) as Update;
update.BuildParametersAsValue = true;
using (var dbExecutor = userConnection.EnsureDBConnection())
{
try
{
dbExecutor.StartTransaction();
var affectedRowsCount = update.Execute(dbExecutor);
dbExecutor.CommitTransaction();
}
catch (Exception ex)
{
dbExecutor.RollbackTransaction();
}
}
}
var rootProjectId = cProjects[0].GetRootId();
var endDate = cProjects.Last().EndDate;
Update updateRoot = new Update(userConnection, "Project")
.Set("EndDate", Column.Const(endDate))
.Where("Id").IsEqual(Column.Const(rootProjectId)) as Update;
updateRoot.BuildParametersAsValue = true;
using (var dbExecutor = userConnection.EnsureDBConnection())
{
try
{
dbExecutor.StartTransaction();
var affectedRowsCount = updateRoot.Execute(dbExecutor);
dbExecutor.CommitTransaction();
}
catch (Exception ex)
{
dbExecutor.RollbackTransaction();
}
}
}
示例2: EditData
private int EditData(IConnectinContext cc,ObjectMapper om)
{
if (om.ID == null)
throw new PeanutException(DataMsg.UPDATE_ERROR_ID_NOTFOUND);
Update update = new Update(om.Table);
for (int i = 0; i < om.Properties.Count; i++)
{
PropertyMapper pm= om.Properties[i];
System.Reflection.PropertyInfo pi = pm.Handler.Property;
if (EntityState._FieldState.ContainsKey(pm.Handler.Property.Name))
{
if (pm.Cast != null)
{
update.AddField(pm.ColumnName,"p_"+pi.Name,pm.Cast.ToColumn(pm.Handler.Get(this),
pm.Handler.Property.PropertyType,this));
}
else
{
update.AddField(pm.ColumnName, "p_" + pi.Name, pm.Handler.Get(this));
}
}
}
update.Where.SqlText.Append(om.ID.ColumnName).Append("[email protected]");
update.Where.Parameters.Add(new Command.Parameter { Name = "p1", Value = om.ID.Handler.Get(this) });
return update.Execute(cc);
}