private static void BuildValues(IList <PropertyInfo> props, object vacancy, string typeIdProperty, StringBuilder sqlBuilder) { for (var i = 0; i < props.Count; i++) { var prop = props[i]; var name = prop.Name; var propValue = prop.GetValue(vacancy, null); var isAttributeMapped = prop.CustomAttributes.FirstOrDefault( attributeData => attributeData.AttributeType == typeof(NotMappedAttribute)) == null; if (name != typeIdProperty && isAttributeMapped) { if (propValue == null) { sqlBuilder.Append("NULL"); } else { var formattedValue = InstanceFormatter.FormatTypeInstance(propValue, prop.PropertyType); sqlBuilder.Append(formattedValue); } sqlBuilder.Append(i != props.Count - 1 ? ", " : ")"); } else { sqlBuilder.Replace(",", "", sqlBuilder.Length - 2, 2); sqlBuilder.Append(i != props.Count - 1 ? "" : ")"); } } }
public string Format(object value) { return(InstanceFormatter.FormatTypeInstance(value, value.GetType())); }