public void CreateClassFromSqlQueryUsingAdoDataReader2() { var query = $"select * from {TableName}"; var cSharpClass = CSharpClassGeneratorFromAdoDataReader .GenerateClass(SqlConnectionProviders.AdventureWorksDb, query, "Employee"); Console.WriteLine(cSharpClass); }
public void CreateClassFromSqlQueryUsingAdoDataReader() { var query = "select * from sys.types"; var cSharpClass = CSharpClassGeneratorFromAdoDataReader .GenerateClass(SqlConnectionProviders.AdventureWorksDb, query, "SysType"); Console.WriteLine(cSharpClass); }
public void CreateClassForDescribeResultSet() { var query = "sp_describe_first_result_set @tsql = N'SELECT object_id, name, type_desc FROM sys.indexes'"; var cSharpClass = CSharpClassGeneratorFromAdoDataReader.GenerateClass(SqlConnectionProviders.AdventureWorksDb, query, "DescribeResultSetRow", CSharpClassTextGeneratorOptions.Default); Console.WriteLine(cSharpClass); }
public void CreateClassForUserDefinedTypes() { var query = "select * from sys.types where is_user_defined = 1"; var cSharpClass = CSharpClassGeneratorFromAdoDataReader.GenerateClass(SqlConnectionProviders.AdventureWorksDb, query, "SqlSysType", CSharpClassTextGeneratorOptions.Default); Console.WriteLine(cSharpClass); }
public void FromAdoDataReader() { var text = CSharpClassGeneratorFromAdoDataReader.GenerateClass( SqlConnectionProvider, SqlSelectFromPoDetail, PoDetailClassName, CSharpClassTextGeneratorOptions.Default); Console.WriteLine(text); }
private void GenerateCode() { try { var sqlConnectionProvider = SelectedSqlConnection.Value.SqlConnectionProvider; var cSharpClass = CSharpClassGeneratorFromAdoDataReader.GenerateClass(sqlConnectionProvider, SqlQuery.Value, ClassName.Value); GeneratedCode.Value = cSharpClass; } catch (Exception e) { MessageBox.Show(string.Join(Environment.NewLine, e.Message, e.StackTrace, e.ToString())); } }
public void ConvertSqlResultsToDesignTimeData() { { var className = "Item"; var sqlQuery = "SELECT TOP 2 * FROM ITEM"; var conn = SqlConnectionProviders.PbsiCopy; var results = conn.GetSqlConnection().Query(sqlQuery).ToList(); var json = JsonConvert.SerializeObject(results); var classDeclaration = CSharpClassGeneratorFromAdoDataReader.GenerateClass(conn, sqlQuery, className); var designTimeCode = DesignTimeDataCodeTemplate.CreateCode("Item", json, classDeclaration); Console.WriteLine(designTimeCode); } }
private void GenerateCSharpClassDefinition() { try { var options = new CSharpClassTextGeneratorOptions(); options.IncludePropertyAnnotationAttributes = IncludePropertyAttributes.Value; var conn = DatabaseSelectionController.GetDbConnection(); GeneratedCSharpText.Value = CSharpClassGeneratorFromAdoDataReader.GenerateClass(conn, SqlQuery.Value, ClassName.Value, options); } catch (Exception e) { MessageBox.Show(e.ToString()); } }
public void CreateClassFromSqlForActualUseWhenNeedingToGenerateCSharpClasses_UsingEpicorTest905() { var sql = @" SELECT pb.Company ,pb.BinNum ,pb.PartNum as EpicorPartNumber ,CASE WHEN SUM(pb.OnhandQty) IS NULL THEN 0 ELSE SUM(pb.OnhandQty) END as OnHandQty ,pb.DimCode FROM PartBin pb WHERE pb.WarehouseCode = 'DC' and pb.binnum = 'S1' GROUP BY pb.Company ,PartNum ,pb.BinNum ,pb.DimCode"; var cSharpClass = CSharpClassGeneratorFromAdoDataReader.GenerateClass(SqlConnectionProviders.EpicorTest905, sql, "EpicorItemInventory"); Console.WriteLine(cSharpClass); }