/// <summary> /// Builds the SQL parameter list. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="poco">The poco.</param> /// <returns>List<DbParameter>.</returns> public List <DbParameter> BuildDbParameterList <T>(T poco, Func <string, object, DbParameter> GetNewParameter, IXmlSerializer XmlSerializer, IJsonSerializer JsonSerializer, ICsvSerializer CsvSerializer) where T : class { var list = new List <DbParameter>() { }; ExtFastMember.GetAdvanceMembers(poco).ForEach(delegate(AdvanceMember p) { var validation = DataValidation.IsValidBasedOnSqlColumnAttributes(p); if (!validation.Item1) { throw new InvalidDataException(string.Join(Environment.NewLine, validation.Item2)); } object parameterValue = DBNull.Value; if (p.SqlCustomAttritube.SerializableType != SerializableType.NONE) { if (p.Member.Type == typeof(string)) { // assuming the string is already serialize and the developer don't know how this library works smh parameterValue = ConvertToDatabaseValue(p.Member, p.Value); } else { if (p.Value == null) { parameterValue = DBNull.Value; } else { switch (p.SqlCustomAttritube.SerializableType) { case SerializableType.XML: XmlSerializer.IsNullThrow(nameof(XmlSerializer), new BadCodeException( $"YOU FOOL!!! Your claiming the property {p.Member.Name} in the type {p.Member.Type.FullName} value is in XML Format but your not specifying how to deserialize/serialize it )")); parameterValue = XmlSerializer.SerializeToString(p.Value); break; case SerializableType.JSON: JsonSerializer.IsNullThrow(nameof(JsonSerializer), new BadCodeException( $"YOU FOOL!!! Your claiming the property {p.Member.Name} in the type {p.Member.Type.FullName} value is in JSON Format but your not specifying how to deserialize/serialize it )")); parameterValue = JsonSerializer.SerializeToString(p.Value); break; case SerializableType.CSV: CsvSerializer.IsNullThrow(nameof(CsvSerializer), new BadCodeException( $"YOU FOOL!!! Your claiming the property {p.Member.Name} in the type {p.Member.Type.FullName} value is in CSV Format but your not specifying how to deserialize/serialize it )")); parameterValue = CsvSerializer.SerializeToString(p.Value); break; default: throw new ArgumentOutOfRangeException(); } //parameterValue = $"'{parameterValue.ToString().Replace("'", @"\'")}'"; } } } else { parameterValue = ConvertToDatabaseValue(p.Member, p.Value); } // var command = GetNewCommand(); list.Add(GetNewParameter($"@{p.Member.Name}", parameterValue)); }); return(list); }