private string GetColumnNameFromMember(MemberExpression node) { ColumnInfo columnInfo = DatabaseMapper.GetTableInfo(node.Member.DeclaringType) .GetColumnInfoByPropertyName(node.Member.Name); return(columnInfo.Name); }
private string GetColumnNameFromMember(MemberExpression node) { TableInfo tableInfo = DatabaseMapper.GetTableInfo(node.Member.DeclaringType); ColumnInfo columnInfo = tableInfo.GetColumnInfoByPropertyName(node.Member.Name); return(tableInfo.Delimiters.QuoteIdentifier(columnInfo.Name)); }
/// <summary> /// Visits the member. /// </summary> /// <param name="expression">The expression.</param> /// <exception cref="System.NotSupportedException">If the member type is not supported.</exception> protected override Expression VisitMember(MemberExpression expression) { if (expression.Expression != null && (expression.Expression.NodeType == ExpressionType.Parameter || expression.Expression.NodeType == ExpressionType.Convert)) { var columnInfo = DatabaseMapper.GetTableInfo(expression.Member.DeclaringType).GetColumnInfoByPropertyName(expression.Member.Name); LinqStringBuilder.Append(columnInfo.Name); return(expression); } throw new NotSupportedException(string.Format("The member '{0}' is not supported.", expression.Member.Name)); }
public void ReturnTableInfoForType() { var modelMapper = NSubstitute.Substitute.For <IModelMapper>(); var tableInfo = new TableInfo(new List <ColumnInfo>(), new List <PropertyInfo>(), null); modelMapper.GetTableInfo <Foo>().Returns(tableInfo); modelMapper.GetTableInfo(Arg.Any <Type>()).Returns(tableInfo); var databaseModelMapper = new DatabaseMapper(modelMapper); var expected = tableInfo; var actual = databaseModelMapper.GetTableInfo <Foo>(); actual.Should().Be(expected); }