private static IDictionary <string, object> DoInsert(InvokeMemberBinder binder, object[] args, DataStrategy dataStrategy, string tableName) { return(binder.HasSingleUnnamedArgument() ? InsertEntity(args[0], dataStrategy, tableName) : InsertDictionary(binder, args, dataStrategy, tableName)); }
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)); }
private static object DoInsert(InvokeMemberBinder binder, object[] args, DataStrategy dataStrategy, string tableName) { if (binder.HasSingleUnnamedArgument()) { return(InsertEntity(args[0], dataStrategy, tableName, (r, e) => false, !binder.IsResultDiscarded())); } if (args.Length == 2) { var onError = args[1] as ErrorCallback; if (onError != null) { return(InsertEntity(args[0], dataStrategy, tableName, onError, !binder.IsResultDiscarded())); } } return(InsertDictionary(binder, args, dataStrategy, tableName)); }
public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args) { object result; if (binder.HasSingleUnnamedArgument() || args.Length == 2 && args[1] is ErrorCallback) { result = UpsertByKeyFields(table.GetQualifiedName(), dataStrategy, args[0], MethodNameParser.ParseCriteriaNamesFromMethodName(binder.Name), !binder.IsResultDiscarded(), args.Length == 2 ? (ErrorCallback)args[1] : ((item, exception) => false)); } else { var criteria = MethodNameParser.ParseFromBinder(binder, args); var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteria); var data = binder.NamedArgumentsToDictionary(args); result = dataStrategy.Run.Upsert(table.GetQualifiedName(), data, criteriaExpression, !binder.IsResultDiscarded()); } return(ResultHelper.TypeResult(result, table, dataStrategy)); }