本文整理汇总了C#中DataStrategy.Update方法的典型用法代码示例。如果您正苦于以下问题:C# DataStrategy.Update方法的具体用法?C# DataStrategy.Update怎么用?C# DataStrategy.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataStrategy
的用法示例。
在下文中一共展示了DataStrategy.Update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateByKeyFields
internal static object UpdateByKeyFields(string tableName, DataStrategy dataStrategy, object entity, IEnumerable<string> keyFieldNames)
{
var record = ObjectToDictionary(entity);
var criteria = GetCriteria(keyFieldNames, record);
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(tableName, criteria);
return dataStrategy.Update(tableName, record, criteriaExpression);
}
示例2: UpdateUsingKeys
private static object UpdateUsingKeys(DataStrategy dataStrategy, DynamicTable table, object[] args)
{
var record = ObjectToDictionary(args[0]);
var list = record as IList<IDictionary<string, object>>;
if (list != null) return dataStrategy.UpdateMany(table.GetQualifiedName(), list);
var dict = record as IDictionary<string, object>;
return dataStrategy.Update(table.GetQualifiedName(), dict);
}
示例3: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
var criteria = args.OfType<SimpleExpression>().SingleOrDefault() ?? new SimpleEmptyExpression();
var data = binder.NamedArgumentsToDictionary(args).Where(kv=>!(kv.Value is SimpleExpression)).ToDictionary();
var updatedCount = dataStrategy.Update(table.GetQualifiedName(), data, criteria);
return updatedCount.ResultSetFromModifiedRowCount();
}
示例4: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
if (args.Length != 1) throw new ArgumentException("Incorrect number of arguments to Update method.");
var record = ObjectToDictionary(args[0]);
var list = record as IList<IDictionary<string, object>>;
if (list != null) return dataStrategy.UpdateMany(table.GetQualifiedName(), list);
var dict = record as IDictionary<string, object>;
return dataStrategy.Update(table.GetQualifiedName(), dict);
}
示例5: UpdateByKeyFields
internal static object UpdateByKeyFields(string tableName, DataStrategy dataStrategy, object entity, IEnumerable<string> keyFieldNames)
{
var record = ObjectToDictionary(entity);
var list = record as IList<IDictionary<string, object>>;
if (list != null) return dataStrategy.UpdateMany(tableName, list, keyFieldNames.ToList());
var dict = record as IDictionary<string, object>;
var criteria = GetCriteria(keyFieldNames, dict);
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(tableName, criteria);
return dataStrategy.Update(tableName, dict, criteriaExpression);
}
示例6: Execute
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
{
if (binder.HasSingleUnnamedArgument())
{
return UpdateByKeyFields(table.GetQualifiedName(), dataStrategy, args[0],
MethodNameParser.ParseCriteriaNamesFromMethodName(binder.Name));
}
var criteria = MethodNameParser.ParseFromBinder(binder, args);
var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteria);
var data = binder.NamedArgumentsToDictionary(args)
.Where(kvp => !criteria.ContainsKey(kvp.Key))
.ToDictionary();
return dataStrategy.Update(table.GetQualifiedName(), data, criteriaExpression);
}
示例7: UpdateUsingOriginalValues
private static object UpdateUsingOriginalValues(DataStrategy dataStrategy, DynamicTable table, object[] args)
{
var newValues = ObjectToDictionary(args[0]);
var newValuesList = newValues as IList<IDictionary<string, object>>;
if (newValuesList != null)
{
var originalValuesList = ObjectToDictionary(args[1]) as IList<IDictionary<string, object>>;
if (originalValuesList == null) throw new InvalidOperationException("Parameter type mismatch; both parameters to Update should be same type.");
return dataStrategy.UpdateMany(table.GetQualifiedName(), newValuesList, originalValuesList);
}
var newValuesDict = newValues as IDictionary<string, object>;
var originalValuesDict = ObjectToDictionary(args[1]) as IDictionary<string, object>;
if (originalValuesDict == null) throw new InvalidOperationException("Parameter type mismatch; both parameters to Update should be same type.");
return dataStrategy.Update(table.GetQualifiedName(), newValuesDict, originalValuesDict);
}