public override void SetTable( SqlTable table, MemberInfo member, IEnumerable <Expression> expArgs, IEnumerable <ISqlExpression> sqlArgs) { var method = member as MethodInfo; if (method == null) { throw new ArgumentNullException("member"); } var paramsList = method.GetParameters().ToList(); var valuesList = expArgs.Cast <ConstantExpression>().ToList(); if (paramsList.Count != valuesList.Count) { throw new TargetParameterCountException("Invalid number of parameters"); } var sqlValues = new List <ISqlExpression>(); for (var i = 0; i < paramsList.Count; i++) { var val = valuesList[i].Value; if (val == null) { continue; } var p = paramsList[i]; sqlValues.Add(new SqlValue("$$" + p.Name + "$$")); sqlValues.Add(new SqlValue(ValueToString(val))); } var arg = new ISqlExpression[1]; arg[0] = new SqlExpression( String.Join(", ", Enumerable.Range(0, sqlValues.Count) .Select(x => "{" + x + "}")), sqlValues.ToArray()); table.SqlTableType = SqlTableType.Expression; table.Name = "{0}('PLACEHOLDER' = {2}) {1}"; table.TableArguments = arg.ToArray(); }
public override void SetTable(ISqlBuilder sqlBuilder, MappingSchema mappingSchema, SqlTable table, MethodCallExpression methodCall, Func <Expression, ColumnDescriptor?, ISqlExpression> converter) { var method = methodCall.Method; if (method == null) { throw new ArgumentNullException(nameof(methodCall)); } var paramsList = method.GetParameters().ToList(); var valuesList = methodCall.Arguments.Cast <ConstantExpression>().ToList(); if (paramsList.Count != valuesList.Count) { throw new TargetParameterCountException("Invalid number of parameters"); } var sqlValues = new List <ISqlExpression>(); for (var i = 0; i < paramsList.Count; i++) { var val = valuesList[i].Value; if (val == null) { continue; } var p = paramsList[i]; sqlValues.Add(new SqlValue("$$" + p.Name + "$$")); sqlValues.Add(new SqlValue(ValueToString(val) !)); } var arg = new ISqlExpression[1]; arg[0] = new SqlExpression( string.Join(", ", Enumerable.Range(0, sqlValues.Count) .Select(x => "{" + x + "}")), sqlValues.ToArray()); table.SqlTableType = SqlTableType.Expression; table.Name = "{0}('PLACEHOLDER' = {2}) {1}"; table.TableArguments = arg.ToArray(); }
public override void SetTable(MappingSchema mappingSchema, SqlTable table, MemberInfo member, IEnumerable<Expression> expArgs, IEnumerable<ISqlExpression> sqlArgs) { var method = member as MethodInfo; if (method == null) throw new ArgumentNullException("member"); var paramsList = method.GetParameters().ToList(); var valuesList = expArgs.Cast<ConstantExpression>().ToList(); if (paramsList.Count != valuesList.Count) throw new TargetParameterCountException("Invalid number of parameters"); var sqlValues = new List<ISqlExpression>(); for(var i = 0; i < paramsList.Count; i++) { var val = valuesList[i].Value; if (val == null) continue; var p = paramsList[i]; sqlValues.Add(new SqlValue("$$" + p.Name + "$$")); sqlValues.Add(new SqlValue(ValueToString(val))); } var arg = new ISqlExpression[1]; arg[0] = new SqlExpression( String.Join(", ", Enumerable.Range(0, sqlValues.Count) .Select(x => "{" + x + "}")), sqlValues.ToArray()); table.SqlTableType = SqlTableType.Expression; table.Name = "{0}('PLACEHOLDER' = {2}) {1}"; table.TableArguments = arg.ToArray(); }