/// <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)); }
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); }
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)); }