コード例 #1
0
 /// <summary>
 /// Proccesses a member expression.
 /// </summary>
 /// <param name="expression">The member expression.</param>
 /// <returns>The result of the processing.</returns>
 protected virtual string MemberToColumn(MemberExpression expression)
 {
     return(Resolvers.Column((PropertyInfo)expression.Member));
 }
コード例 #2
0
        private static string BuildUpdateQuery(Type type)
        {
            if (!UpdateQueryCache.TryGetValue(type.TypeHandle, out var sql))
            {
                var tableName   = Resolvers.Table(type);
                var keyProperty = Resolvers.KeyProperty(type);

                // Use all properties which are settable.
                var typeProperties = Resolvers.Properties(type)
                                     .Where(p => p != keyProperty)
                                     .Where(p => p.PropertyInfo.GetSetMethod() != null)
                                     .ToArray();

                var columnNames = typeProperties.Select(p => $"{Resolvers.Column(p)} = @{p.Name}").ToArray();

                sql = $"update {tableName} set {string.Join(", ", columnNames)} where {Resolvers.Column(keyProperty)} = @{keyProperty.Name}";

                UpdateQueryCache.TryAdd(type.TypeHandle, sql);
            }

            return(sql);
        }
コード例 #3
0
 public void Column_NoCacheConflictNestedClass()
 {
     Assert.Equal("[BazA]", Resolvers.Column(typeof(Foo.Bar).GetProperty("Baz"), _sqlBuilder));
     Assert.Equal("[BazB]", Resolvers.Column(typeof(Baz.Bar).GetProperty("Baz"), _sqlBuilder));
 }