/// <summary> /// Convert common operation for an Member /// </summary> public string ConvertCommonOperations(MemberExpression expression) { PropertyInfo property = expression.Member as PropertyInfo; if (property != null && property.PropertyType == typeof(bool)) { return(WmiQueryUtility.ConvertBinaryBooleanToSQL(expression.Member, true)); } return(WmiQueryUtility.ConvertMemberToSql(expression.Member)); }
/// <summary> /// This is cheating, the most ideal way of converting expression trees is to convert /// the LINQ syntax first to a custom tree and parse that, and covert the standalone /// boolean member expressions to binary expressions. Because of a LINQ defect /// the /// </summary> private string HandleNotNodeType(UnaryExpression expression) { MemberExpression member = expression.Operand as MemberExpression; if (member != null) { PropertyInfo property = member.Member as PropertyInfo; if (property != null && property.PropertyType == typeof(Boolean)) { return(WmiQueryUtility.ConvertBinaryBooleanToSQL(member.Member, false)); } } return(Context.Visit(expression.Operand)); }
public override string Visit(BinaryExpression expression) { string where = null; where += Context.Visit(expression.Left); where += WmiQueryUtility.ConvertBinaryTypeToSql(expression.NodeType); if (expression.Right.Type == typeof(String)) { where += String.Format("'{0}'", Context.Visit(expression.Right)); } else { where += Context.Visit(expression.Right); } return(where); }
/// <summary> /// Converts an binary where boolean expression to an SQL syntax /// </summary> public static string ConvertBinaryBooleanToSQL(MemberInfo memberInfo, bool value) { return(string.Format("{0} = {1}", WmiQueryUtility.ConvertMemberToSql(memberInfo), value)); }