pdsahaystackch13-haystackxmlfiles
DESCRIPTION
PDSAHaystackCh13-HaystackXmlFilesTRANSCRIPT
-
Chapter 13
Haystack XML Files TableofContents
Chapter 13 ................................................................................................................... 13-1
Haystack XML Files ..................................................................................................... 13-1
Overview of Haystack XML Files ...................................................................... 13-2Reason for XML Files ........................................................................... 13-3??_DotNetTypes XML File .................................................................... 13-3??_TemplateGroups XML File .............................................................. 13-4DatabaseServers XML File ................................................................... 13-4Languages XML File ............................................................................. 13-5??_DBTypes XML File .......................................................................... 13-6??_DBTypesExcludes XML File ........................................................... 13-6??_SPSettings XML File ....................................................................... 13-7??_Templates XML File ........................................................................ 13-7Prefixes XML File .................................................................................. 13-7ReservedWords XML File ..................................................................... 13-8
Relationships between XML Files .................................................................... 13-8.NET Language XML Files .................................................................... 13-8Template Group XML Files ................................................................... 13-9Database Servers XML Files ................................................................ 13-9Database Servers and SQL Generation XML Files ............................ 13-10
Add New Code Generation Template............................................................. 13-11
.NET Language Templates ............................................................................ 13-11
Database Templates ...................................................................................... 13-12
Add New Default Dynamic SQL Statement .................................................... 13-12
Add New Default Stored Procedure ............................................................... 13-12
Modifying .NET Type Defaults ........................................................................ 13-13
-
Haystack XML Files
13-2 Haystack Code Generator for .NET Copyright 2010-2011 by PDSA, Inc.
All rights reserved. Reproduction is strictly prohibited.
Adding New Database Data Types ................................................................ 13-13
Prefix Replacement XML ................................................................................ 13-13
Reserved Words XML .................................................................................... 13-13
Chapter Index ................................................................................................. 13-14
Overview of Haystack XML Files This document describes the use of the various XML Files that control how Haystack works and generates code. In the [InstallFolder]\Haystac\Xml folder is where you will find a lot of XML files. Haystack relies on these XML files to control how it works. There are no hard coded values for a specific language features (C# or VB), or for any specific database such as SQL Server or Oracle. Instead all language or database specific information is in these XML files, or in some cases, in the Haystack.exe.Config file. You may add, edit and delete rows from any of the XML files if you need to. It is very important that you do not modify the structure of the XML files as these are tied to a schema definition file (.XSD) . This means that you may not add or remove any XML elements from these files.
NOTE: After any changes are made to any of the XML files, you will need to re-start Haystack.
Table 1 is a list of the various XML files that you will find in the XML folder. Where you find the double question marks (??) is where you substitute the language or database server you are using. For example, ??_DotNetTypes, could mean CS_DotNetTypes if you are using C# or VB_DotNetTypes if using Visual Basic. The same goes for SQL Server and Oracle.
XML File Name Description
??_DotNetTypes Contains information about each .NET data type for the language you are using.
??_TemplateGroups Contains the list of all the various templates that are used to generate data classes, WPF user controls, Silverlight user controls, ASP.NET user controls, and SQL code.
DatabaseServers Contains the list of the database servers that are supported by
-
Overview of Haystack XML Files
Haystack Code Generator for .NET 13-3 Copyright 2010-2011 by PDSA, Inc. All rights reserved. Reproduction is strictly prohibited.
Haystack.
Languages Contains the list of the .NET languages that are supported by Haystack.
??_DBTypes Contains information about each database data type for the database server that you are using.
??_DBTypesExcludes Contains information about each database data type that you do not want to generate a property for. This would be used for large BLOB or large string types that you might want to load dynamically and not automatically when you select all columns. This can help with performance of your .NET application.
??_SPSettings Contains information about stored procedures in your particular database.
??_Templates Contains a list of all the SQL and stored procedure templates that will be generated when you bring up a table in the Haystack Table Information screen.
Prefixes A list of prefixes on columns on your tables that you wish to remove. For example, if you are using Hungarian notation for the fields in your columns, you can remove the prefixes prior to generating public property names for your columns.
ReservedWords Contains a set of reserved words in .NET. If one of your columns in one of your tables, views or stored procedures matches any words in this xml file, then that name will be replaced with the ReplaceWith value in this XML file. This will ensure that no compile errors will occur from generated code because of a reserved word.
Table 1: Overview of Haystack XML files.
You will find the schema files for each of the above XML files in the [InstallFolder]\Haystack\Xsd folder.
Reason for XML Files Instead of storing all of the various information that you find in these XML files into database tables, we found XML files are so much more generic and require much less work and maintenance. There are too many differences between database engines and trying to maintain CRUD SQL for each database engine would require too much maintenance.
??_DotNetTypes XML File Below is a list of the elements contained in this XML file and a description of what is contained in each element.
-
Haystack XML Files
13-4 Haystack Code Generator for .NET Copyright 2010-2011 by PDSA, Inc.
All rights reserved. Reproduction is strictly prohibited.
Element Description
DotNetType The generic .NET CLR Type
LanguageType The specific language type that is used. For example, System.Decimal would be the CLR type, yet decimal would be the type for C#.
GenericType The generic type for this .NET type. Examples are StringType, NumericType, BinaryType, etc.
Prefix If you wish to prefix your private variables/fields in your class with Hungarian notation, you can set this value to the prefix you wish to use.
IsNullableType Set to true if this .NET type can be a .NET nullable type.
DefaultValue The default value to assign to this property when initializing variables.
ValueForNull What value you want to return if the value read from the database is a null.
ConvertMethod The Convert.To??? method to use when generating code.
GetNetTypeMethod The .???() method to use when generating code.
??_TemplateGroups XML File Below is a list of the elements contained in this XML file and a description of what is contained in each element.
Element Description
GroupName The template group name.
TemplateFileName The name of the xml file that holds the list of templates to generate.
IsSelected Is this item group going to be generated?
DatabaseServers XML File Below is a list of the elements contained in this XML file and a description of what is contained in each element.
Element Description
Name
ProviderName
DBDataTypesFile
DBDataTypesExcludeFile
-
Overview of Haystack XML Files
Haystack Code Generator for .NET 13-5 Copyright 2010-2011 by PDSA, Inc. All rights reserved. Reproduction is strictly prohibited.
SPSettingsFile
TemplatesFile
TemplatesPath
SPBlankFile
AllowSPGeneration
UsePrecisionScale
CommandParameterPrefix
SPParameterPrefix
AndOperator
OrOperator
Languages XML File Below is a list of the elements contained in this XML file and a description of what is contained in each element.
Element Description
Name
Code
DotNetTypesFile
TemplateGroupFile
Self
TrueValue
FalseValue
LineEnding
Comment
And
Or
NullablePattern
SystemTypeOf
-
Haystack XML Files
13-6 Haystack Code Generator for .NET Copyright 2010-2011 by PDSA, Inc.
All rights reserved. Reproduction is strictly prohibited.
??_DBTypes XML File Below is a list of the elements contained in this XML file and a description of what is contained in each element.
Element Description
DBtype
DBTypeNumber
GenericType
MaxLength
Precision
MinScale
MaxScale
UseMaxLength
IsNullable
IncludeSize
IsInsertable
IsUpdatable
IncludeInAuditTracking
DotNetType
DbTypeEnum
??_DBTypesExcludes XML File Below is a list of the elements contained in this XML file and a description of what is contained in each element.
Element Description
DataType
IsSelectable
IsInsertable
IsUpdatable
-
Overview of Haystack XML Files
Haystack Code Generator for .NET 13-7 Copyright 2010-2011 by PDSA, Inc. All rights reserved. Reproduction is strictly prohibited.
??_SPSettings XML File Below is a list of the elements contained in this XML file and a description of what is contained in each element.
Element Description
SkipWithThisPrefix
RemoveSuffixAfterThisCharacter
??_Templates XML File Below is a list of the elements contained in this XML file and a description of what is contained in each element.
Element Description
EnumName
IsAll
CodeType
DBObjectTypes
RegenOnChange
SQLFileName
SPFileName
SPPrefix
SPSuffix
Prefixes XML File Below is a list of the elements contained in this XML file and a description of what is contained in each element.
Element Description
PrefixToStrip
-
Haystack XML Files
13-8 Haystack Code Generator for .NET Copyright 2010-2011 by PDSA, Inc.
All rights reserved. Reproduction is strictly prohibited.
ReservedWords XML File Below is a list of the elements contained in this XML file and a description of what is contained in each element.
Element Description
Word
ReplaceWith
Relationships between XML Files The XML files do have relationships between them. You need to be careful to completely understand these relationships prior to modifying any of the XML files. Lets take a look at some of these relationships.
.NET Language XML Files Figure 1 shows the relationship that starts with the Languages file. For each language there is a ??_DotNetTypes.xml file that contains the list of .NET data types for that language. So this is a one-to-many relationship. There is also another one-to-many relation to another XML file called ??_TemplateGroups.xml. In this file is the list of templates that can be generated for this language. The set of templates can be data classes, WPF and Silverlight user controls, etc.
Figure 1: .NET Language XML File Relationships
-
Relationships between XML Files
Haystack Code Generator for .NET 13-9 Copyright 2010-2011 by PDSA, Inc. All rights reserved. Reproduction is strictly prohibited.
Template Group XML Files A template group is used to create a list of different templates that can be generated for a particular language as shown in Figure 2. Each entry in the ??_TemplateGroups file has a separate XML file that will contain a list of text files that can be used for code generation against a table, view, stored procedure or XML files.
Figure 2: Template Groups XML Relationship
Database Servers XML Files Haystack has the ability to support different database engines. For each engine there has to not only be a database provider DLL, but also the corresponding entries in the XML files shown in Figure 3. It is not a trivial task for Haystack to add a new database server. However, it is much simpler because of the Provider Model that is used in our DLLs and because there is no hard coding of database-specific nuances.
-
Haystack XML Files
13-10 Haystack Code Generator for .NET Copyright 2010-2011 by PDSA, Inc.
All rights reserved. Reproduction is strictly prohibited.
Figure 3: Database Servers XML Relationships
Database Servers and SQL Generation XML Files When you click on the Info button next to a table or a view, some default SQL statements and/or stored procedures are generated. All this information comes from text files. Which text files are used is determined by the information in the SqlServer_Templates.xml/Oracle_Templates.xml files (Figure 4). Depending on the database provider you choose, the appropriate xml file is chosen and the appropriate SQL text is sent through the Haystack code generation process to create the SQL/Stored Procedures.
-
Add New Code Generation Template
Haystack Code Generator for .NET 13-11 Copyright 2010-2011 by PDSA, Inc. All rights reserved. Reproduction is strictly prohibited.
Figure 4: Database Servers and SQL Generation XML Relationships
Add New Code Generation Template Template Groups.xml \??_Templates\*.xml Text Files
.NET Language Templates Languages.xml ??_DotNetTypes.xml
-
Haystack XML Files
13-12 Haystack Code Generator for .NET Copyright 2010-2011 by PDSA, Inc.
All rights reserved. Reproduction is strictly prohibited.
Database Templates DatabaseServers.xml List of databases supported by haystack ??_Templates.xml List of templates for dynamic SQL and stored procedure ??_DBTypes List of database data types and how they relate to .NET data types ??_DBTypesExclude List of database data types that you do not wish to generate properties for. These are typically large BLOB or large string types that you will only want to retrieve via specialized code ??_SPSettings stored procedure settings
Add New Default Dynamic SQL Statement
Add New Default Stored Procedure
-
Modifying .NET Type Defaults
Haystack Code Generator for .NET 13-13 Copyright 2010-2011 by PDSA, Inc. All rights reserved. Reproduction is strictly prohibited.
Modifying .NET Type Defaults
Adding New Database Data Types
Prefix Replacement XML
Reserved Words XML
-
Haystack XML Files
13-14 Haystack Code Generator for .NET Copyright 2010-2011 by PDSA, Inc.
All rights reserved. Reproduction is strictly prohibited.
Summary In this chapter you learned about the various XML files that make up the Haystack code generator.
Chapter Index
..NET Language XML Files, 13-8
DDatabase Servers and SQL Generation
XML Files, 13-10 Database Servers XML File, 13-9 DatabaseServers XML File, 13-4 DBTypes XML File, 13-6 DBTypesExcludes XML File, 13-6 DotNetTypes XML File, 13-3
HHaystack XML Files, 13-2
LLanguages XML File, 13-5
OOverview of Haystack XML Files, 13-2
PPrefixes XML File, 13-7
RReason for XML Files, 13-3 Relationships between XML Files, 13-8 ReservedWords XML File, 13-8
SSPSettings XML File, 13-7
TTemplate Group XML Files, 13-9 TemplateGroups XML File, 13-4 Templates XML File, 13-7
XXML Files for Haystack, 13-2 XML Folder, 13-2 XML Relationships, 13-8 XSD Files, 13-2 XSD Folder, 13-3