private string FormatNumber(object value) { decimal num; if (Decimal.TryParse(value.ToString(), NumberStyles.Number, CultureInfo.InvariantCulture, out num)) { return(HqlRestrictions.FormatValue(value)); } else { return(""); } }
public void InSubquery(string propertyName, string subquery, Dictionary <string, object> parameters) { string subqueryWithParameters = ""; Regex re = new Regex(@"(?<![^\s]):[^\s]+"); subqueryWithParameters = re.Replace(subquery, x => { object param; if (parameters.TryGetValue(x.ToString().TrimStart(':'), out param)) { var typeCode = Type.GetTypeCode(param.GetType()); switch (typeCode) { case TypeCode.String: case TypeCode.DateTime: return(HqlRestrictions.FormatValue(param)); case TypeCode.UInt16: case TypeCode.UInt32: case TypeCode.UInt64: case TypeCode.Int16: case TypeCode.Int32: case TypeCode.Int64: case TypeCode.Decimal: case TypeCode.Double: return(FormatNumber(param)); default: return(""); } } return(""); }); Criterion = InSubquery(propertyName, subqueryWithParameters); }