/// <param name="node">The expression to visit.</param> /// <returns>The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.</returns> protected override Expression VisitMember(MemberExpression node) { if (node.Member.DeclaringType == typeof(TDataObject) || typeof(TDataObject).IsSubclassOf(node.Member.DeclaringType)) { string mappedFieldName = mappingResolver.ResolveFieldName <TDataObject>(node.Member.Name); Out(mappedFieldName); } else { if (node.Member is FieldInfo) { ConstantExpression ce = node.Expression as ConstantExpression; FieldInfo fi = node.Member as FieldInfo; object fieldValue = fi.GetValue(ce.Value); Expression constantExpr = Expression.Constant(fieldValue); Visit(constantExpr); } else { throw new NotSupportedException(string.Format(Resources.EX_MEMBER_TYPE_NOT_SUPPORT, node.Member.GetType().FullName)); } } return(node); }
/// <summary> /// Gets the name of the field by using the specified property name. /// </summary> /// <typeparam name="T">The type of the object.</typeparam> /// <param name="propertyName">The property name.</param> /// <returns>The field name in relational database tables.</returns> protected virtual string GetFieldName <T>(string propertyName) where T : class, new() { return(mappingResolver.ResolveFieldName <T>(propertyName)); }
private void OutMember(Expression instance, MemberInfo member) { string mappedFieldName = mappingResolver.ResolveFieldName <TDataObject>(member.Name); Out(mappedFieldName); }
protected virtual string GetSelectCriteria <T>(PropertyBag criteria) where T : class, new() { return(string.Join(" AND ", criteria.Select(p => string.Format("{0}={1}{2}", mappingResolver.ResolveFieldName <T>(p.Key), GetWhereClauseBuilder <T>().ParameterChar, mappingResolver.ResolveFieldName <T>(p.Key).ToLower())).ToArray())); }