public static string BuildWhereCondition(Type typ, string columnName, string columnValue) { string whereCondition = string.Empty; PropertyInfo columnInfo = typeof(typ).GetProperty(columnName); if (columnInfo != null) { if (columnInfo.PropertyType == typeof(int)) { whereCondition = columnName + "=" + columnValue; } else if (columnInfo.PropertyType == typeof(String)) { whereCondition = columnName + " LIKE '%" + columnValue + "%'"; } else if (columnInfo.PropertyType == typeof(DateTime)) { whereCondition = columnName + "='" + columnValue + "'"; } } return whereCondition; }
typeof(typ)
Type
if(typ.Equals(System.Int)) { // ... }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)