public string GetCriteria(List <ParameterInfo> parameters, string criteriaClassName, NamespaceData namespaceData) { var result = new StringBuilder(); result.Append(Templates.ClassTemplate.Replace(Templates.ClassTag, criteriaClassName) .Replace(Templates.NamespaceTag, namespaceData.Interfaces)) .Replace(" ", "\t"); var parametersSection = new StringBuilder(); parameters.ForEach(p => { parametersSection.AppendLine($"\t\tpublic {_cSharpClassNameConverter.GetCSharpName(p.DotNetType, p.IsNullable)} {FirstCharToUpper(p.ParameterName)} {{ get; set; }}"); }); return(result.ToString().Replace(Templates.PropertiesTag, parametersSection.ToString())); }
private void PopulateResults(Procedure procedure, StoreProcedureMetadata result, SqlConnection conn) { using (var cmd = conn.CreateCommand()) { cmd.CommandText = procedure.Name; cmd.CommandType = CommandType.StoredProcedure; result.Parameters.ForEach(p => { var dotNetType = _sqlTypeConverter.TypeList.First(_ => _.SqlServerTypeName == p.TypeName).DotNetType; var value = (object)DBNull.Value; if (dotNetType != null) { if (dotNetType == typeof(string)) { value = ""; } else { value = Activator.CreateInstance(dotNetType); } } cmd.Parameters.AddWithValue(p.ParameterName, value); }); var listOfResults = new List <DataTable>(); using (var reader = cmd.ExecuteReader()) { listOfResults.Add(reader.GetSchemaTable()); while (reader.NextResult()) { listOfResults.Add(reader.GetSchemaTable()); } } listOfResults.ForEach(r => { var singleResultData = new List <SchemaTableRow>(); foreach (DataRow row in r.Rows) { var newRow = SchemaTableRow.FromDataRow(row); newRow.FriendlyTypeName = _cSharpClassNameConverter.GetCSharpName(newRow.DataType); singleResultData.Add(newRow); } result.Results.Add(singleResultData); }); } }