public static MssqlDtoSchema GetSchema(Type type) { if (!SCHEMA_COLLECTION.ContainsKey(type)) { SCHEMA_COLLECTION.Add(type, MssqlDtoSchemaUtils.GetDtoSchema(type)); } return(SCHEMA_COLLECTION[type]); }
private static string BuildWhereClauseForSingleUpdate <T>() where T : BaseMssqlDto { var entityType = typeof(T); var keyProperties = MssqlDtoSchemaUtils.GetKeyProperties(entityType); if (keyProperties.Count == 0) { throw new Exception("entity must have least one property as KeyAttribute"); } List <string> conditionClauses = new List <string>(); foreach (var keyProperty in keyProperties) { string conditionClause = "{0} = @{1}"; conditionClause = string.Format(conditionClause, keyProperty.Name, keyProperty.Name); conditionClauses.Add(conditionClause); } if (conditionClauses.Count > 0) { return(string.Format("where {0}", string.Join(" and ", conditionClauses))); } return(""); }