Esempio n. 1
0
        public static void GenerateWhereClause <TEntity, TParams>(this Expression <PredicateSpecificationDelegate <TEntity, TParams> > predicate, StringBuilder commandText, IdentifierQuoter quoter, IQueryMetadata metadata, ParameterSyntaxType entityParameterType)
        {
            var parameterMappings = new Dictionary <Expression, ParameterSyntaxType>
            {
                { predicate.Parameters[0], entityParameterType },
                { predicate.Parameters[1], ParameterSyntaxType.Argument },
            };

            new SqlCodeGeneratorExpressionVisitor(commandText, parameterMappings, metadata, quoter).Visit(predicate.Body);
        }
Esempio n. 2
0
        public static void GenerateUpdateSetList <TEntity, TParams>(this Expression <UpdateSpecificationDelegate <TEntity, TParams> > update, StringBuilder commandText, IdentifierQuoter quoter, IQueryMetadata metadata, ParameterSyntaxType entityParameterType)
        {
            new NewObjectExpressionVisitor(
                n =>
            {
                commandText.AppendFormat("{0} = ", quoter.QuoteName(metadata.ColumnMappings[n.Member.Name]));
                new SqlCodeGeneratorExpressionVisitor(commandText, new Dictionary <Expression, ParameterSyntaxType>
                {
                    { update.Parameters[0], entityParameterType },
                    { update.Parameters[1], ParameterSyntaxType.Argument },
                }, metadata, quoter).Visit(((MemberAssignment)n).Expression);
                commandText.Append(",");
            }
                ).Visit(update);

            commandText.Length--; // Remove last comma
            commandText.AppendLine();
        }