Xml Not matching expected resultsdisabling namespace attributes in serializationWhat does <![CDATA[]]> in XML mean?How do you parse and process HTML/XML in PHP?XmlSerializer obfuscation support?Parsing XML in Windows Phone 7Cloning an instance of object to its base typeRead SOAP XML by ASMX web servcie functionread line and keep spaces from xml fileError using node-soap in NodeJSImport XML into SQL server using OPENXML command with XMLNS

Should I give professor gift at the beginning of my PhD?

Grover algorithm for a database search: where is the quantum advantage?

C++ Arduino IDE receiving garbled `char` from function

How to tell your grandparent to not come to fetch you with their car?

Were Alexander the Great and Hephaestion lovers?

What is the highest possible temporary AC at level 1, without any help from others?

Are there any important biographies of nobodies?

Winning Strategy for the Magician and his Apprentice

How can this tool find out registered domains from an IP?

Why did the Herschel Space Telescope need helium coolant?

Why would future John risk sending back a T-800 to save his younger self?

How come the nude protesters were not arrested?

Is it possible to 'live off the sea'

How to deal with apathetic co-worker?

Is using haveibeenpwned to validate password strength rational?

Is it possible to have a wealthy country without middle class?

Find the limit of a multiplying term function when n tends to infinity.

Does Disney no longer produce hand-drawn cartoon films?

Should an arbiter claim draw at a K+R vs K+R endgame?

Why was the Sega Genesis marketed as a 16-bit console?

What makes an item an artifact?

Impedance ratio vs. SWR

What is the highest possible permanent AC at character creation?

PhD - Well known professor or well known school?



Xml Not matching expected results


disabling namespace attributes in serializationWhat does <![CDATA[]]> in XML mean?How do you parse and process HTML/XML in PHP?XmlSerializer obfuscation support?Parsing XML in Windows Phone 7Cloning an instance of object to its base typeRead SOAP XML by ASMX web servcie functionread line and keep spaces from xml fileError using node-soap in NodeJSImport XML into SQL server using OPENXML command with XMLNS






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am trying to build a schema xml using the following but I am having issues items our being repeated twice and the fields are not being populated.



Basically what happens is the program goes out to sql gets the columns names of the chosen tables then it should produce a schema simlar to as follows not identically in term of values but yes in terms of structure



 public List<TableNames> _tablesNamesList = new List<TableNames>();

public void BuildSchema()


foreach (var table in _tablesNamesList)

PersistentObject _newObject = new PersistentObject();
List<PersistentObject> _newPersistantObjectList = new List<PersistentObject>();

List<TableDefnition> _newList = db.GetALLTableDeiniations(table.TABLE_NAME);

List<FieldSchemaXml> _newFieldList = new List<FieldSchemaXml>();


foreach (var item in _newList)


FieldSchemaXml _newSchema = new FieldSchemaXml();


_newSchema = ConvertSQLDataTypeToSage(item.Type, _newSchema, item);


_newSchema.Name = item.Field;
_newSchema.IsUnique = "false";
_newSchema.IsReadOnly = "false";
_newSchema.IsQueryable = "true";
if (item.is_nullable == 1)


_newSchema.IsNullable = "true";

else

_newSchema.IsNullable = "false";


_newSchema.IsReadOnly = "false";
_newSchema.IsUnique = "false";
_newSchema.Group = "false";

_newSchema.IsLockable = "false";
_newSchema.IsDeltaField = "false";
_newSchema.IsPrimaryKey = "false";
_newSchema.FillType = "None";
_newSchema.Direction = "Input";
_newSchema.OverrideFormatting = "false";
_newSchema.ValueSetByDatabase = "false";
_newSchema.FormatScale = "0";
_newSchema.NegativeFormatting = "Standard";
_newSchema.AggregateFunction = "false";
_newSchema.IsExpression = "false";
_newSchema.IsBrowsable = "true";
_newSchema.IsQueryable = "true";
_newSchema.IsEnumeration = "false";
_newSchema.IsAddInPrimaryKey = "false";
_newSchema.IsExcludedFromReset = "false";
_newSchema.IsMember = "false";
_newSchema.AddInTableName = "";


_newObject.IsCacheable = "false";

_newObject.AllowZeroKeys = "false";
_newObject.TransactionMode = "Required";
_newObject.IsStoredProcedure = "false";
_newObject.ProcedureReturnType = "";
_newFieldList.Add(_newSchema);


_newPersistantObjectList.Add(_newObject);
_newPObject.PersistentObject.AddRange(_newPersistantObjectList);

schemeContent.Text = HelperXml.ToXML(_newPObject);



Example 1.1



 <?xml version="1.0" encoding="utf-8"?>
<ObjectStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:SageObjectStore">
<ApplicationNamespace>BusinessObjects</ApplicationNamespace>
<MemberVariablePrefix>_</MemberVariablePrefix>
<ClassPrefix>Persistent</ClassPrefix>
<ClassSuffix />
<Language>VB</Language>
<Path>C:Sage200SchemaExtensions</Path>
<GenerateBusinessObjects>false</GenerateBusinessObjects>
<GenerateSeparateFiles>false</GenerateSeparateFiles>
<PersistentObjects>
<PersistentObject Name="Customer">
<TableName>SLCustomerAccount</TableName>
<Description />
<Fields>
<Field Name="SLCustomerAccountID">
<DbType>Int64</DbType>
<Precision>19</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>true</IsReadOnly>
<AllowOverwrite>Equal</AllowOverwrite>
<IsPrimaryKey>true</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>true</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>true</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>9999999999999999999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>SLCustomer Account ID</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
</Fields>
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<AlwaysAllowPaging>false</AlwaysAllowPaging>
<Namespace>SalesLedger</Namespace>
<PagingFields />
<TransactionMode>Required</TransactionMode>
<IsStoredProcedure>false</IsStoredProcedure>
<ProcedureReturnType />
</PersistentObject>
<PersistentObject Name="MCSSopOrderss">
<TableName />
<Description />
<Fields>
<Field Name="CustomerID">
<DbType>Int64</DbType>
<Precision>11</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>true</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>99999999999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>



<IsExpression>false</IsExpression>
<FriendlyName>Customer ID</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestDate">
<DbType>Date</DbType>
<Precision>3</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>true</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>99/99/9999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>test</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestString">
<DbType>String</DbType>
<Precision>64</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test String</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestMoney">
<UserDataType>MonetaryValue2dp</UserDataType>
<DbType>String</DbType>
<Precision>12</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Money</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestDecimal">
<DbType>Decimal</DbType>
<Precision>18</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>999999999999999999.</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Decimal</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestCurrency">
<DbType>Currency</DbType>
<Precision>11</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<FormatMask>99999999999.99</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Currency</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="Test">
<DbType>String</DbType>
<Precision>64</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
</Fields>
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<AlwaysAllowPaging>false</AlwaysAllowPaging>
<Namespace />
<PagingFields />
<TransactionMode>Required</TransactionMode>
<IsStoredProcedure>false</IsStoredProcedure>
<ProcedureReturnType />
</PersistentObject>
</PersistentObjects>
<Relationships>
<Relationship>
<ParentObject>Customer</ParentObject>
<ParentKey>SLCustomerAccountID</ParentKey>
<ChildObject>MCSSopOrderss</ChildObject>
<ChildKey>CustomerID</ChildKey>
<InsertOperation>CheckParentExists</InsertOperation>
<DeleteOperation>CheckForAnyChildren</DeleteOperation>
<IsOneToMany>true</IsOneToMany>

</Relationship>
</Relationships>
<DataTypes />
<Enumerations />
<BaselineSchema>C:Program Files (x86)Sage 200
SDKSageObjectStore.xml</BaselineSchema>
</ObjectStore>


However what I am getting is the following For that table there is 44 objects in the field list list so for fields it should be printing that and as you can see its ignorning the name property i am setting on persitent object as well.



 <?xml version="1.0" encoding="utf-16"?>
<ObjectStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<PersistentObjects>
<PersistentObject>
<Fields />
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<TransactionMode>Required</TransactionMode>
<ProcedureReturnType />
<IsStoredProcedure>false</IsStoredProcedure>
</PersistentObject>
</PersistentObjects>
<PersistentObject>
<PersistentObject>
<Fields />
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<TransactionMode>Required</TransactionMode>
<ProcedureReturnType />
<IsStoredProcedure>false</IsStoredProcedure>
</PersistentObject>
</PersistentObject>
</ObjectStore>


My Class for the above.



 public class SageXmlDefiniation

public class ObjectStore


public List<PersistentObject> PersistentObjects = new
List<PersistentObject>();
public string ApplicationnameSpace get; set;
public string MemberVariablePrefix get; set;
public string ClassPrefix get; set;
public string ClassSuffix get; set;
public string Language get; set;
public string Path get; set;
public string GenerateBusinessObjects get; set;
public string GenerateSeparateFiles get; set;

public List<PersistentObject> PersistentObject

get return PersistentObjects;
set PersistentObjects = value;



public class PersistentObject

private List<FieldSchemaXml> _Fields = new List<FieldSchemaXml>();

[XmlAttribute("Name")]
public string Name get; set;

public string TableName get; set;
public string Description get; set;
[XmlArray("Fields")]
[XmlArrayItem("Field")]
public List<FieldSchemaXml> FieldsList

get return _Fields;
set _Fields = value;

public string IsCacheable get; set;
public string AllowZeroKeys get; set;
public string NameSapce get; set;

public string PagingFields get; set;
public string TransactionMode get; set;
public string ProcedureReturnType get; set;
public string IsStoredProcedure get; set;

public class FieldSchemaXml

[XmlAttribute("Name")]
public string Name get; set;

public string DBType get; set;
public string Precision get; set;
public string Scale get; set;
public string FillType get; set;
public string IsNullable get; set;
public string IsReadOnly get; set;
public string AllowOverwrite get; set;
public string IsPrimaryKey get; set;

public string IsDeltaField get; set;
public string IsIndexed get; set;
public string IsTransient get; set;
public string IsUnique get; set;

public string OverrideFormatting get; set;
public string IsLockable get; set;
public string Direction get; set;
public string ValueSetByDatabase get; set;
public string FormatScale get; set;
public string FormatMask get; set;
public string NegativeFormatting get; set;
public string Group get; set;
public string AggregateFunction get; set;
public string IsExcludedFromCopy get; set;
public string IsExpression get; set;
public string FriendlyName get; set;
public string IsBrowsable get; set;
public string IsQueryable get; set;
public string IsEnumeration get; set;

public string IsAddInPrimaryKey get; set;
public string AddInTableName get; set;
public string AddInRelationField get; set;
public string IsMember get; set;
public string IsExcludedFromReset get; set;






My code which returns correct 44 fields for the above table.



public List<TableDefnition> GetALLTableDeiniations(string tableName)

string sql = @"SELECT c.name Field,
t.name Type,
c.max_length MaxLength,
c.Precision,
c.Scale,
c.is_nullable,
c.collation_name
FROM sys.columns c
INNER JOIN sys.types t ON t.system_type_id = c.system_type_id
WHERE object_id = object_id('"+ tableName + "') ORDER BY column_id";

using (var connection = new
sqlConnection(ConfigurationManager.AppSettings["ConnectionString"]))

List<TableDefnition> _tableDefnitions = connection.Query<TableDefnition>(sql).ToList();
return _tableDefnitions;












share|improve this question






















  • I don't see anywhere you set a Name on PersistentObject (which is _newObject). I don't see anywhere you set or add to the FieldsList either.

    – Charles Mager
    Mar 24 at 18:22


















0















I am trying to build a schema xml using the following but I am having issues items our being repeated twice and the fields are not being populated.



Basically what happens is the program goes out to sql gets the columns names of the chosen tables then it should produce a schema simlar to as follows not identically in term of values but yes in terms of structure



 public List<TableNames> _tablesNamesList = new List<TableNames>();

public void BuildSchema()


foreach (var table in _tablesNamesList)

PersistentObject _newObject = new PersistentObject();
List<PersistentObject> _newPersistantObjectList = new List<PersistentObject>();

List<TableDefnition> _newList = db.GetALLTableDeiniations(table.TABLE_NAME);

List<FieldSchemaXml> _newFieldList = new List<FieldSchemaXml>();


foreach (var item in _newList)


FieldSchemaXml _newSchema = new FieldSchemaXml();


_newSchema = ConvertSQLDataTypeToSage(item.Type, _newSchema, item);


_newSchema.Name = item.Field;
_newSchema.IsUnique = "false";
_newSchema.IsReadOnly = "false";
_newSchema.IsQueryable = "true";
if (item.is_nullable == 1)


_newSchema.IsNullable = "true";

else

_newSchema.IsNullable = "false";


_newSchema.IsReadOnly = "false";
_newSchema.IsUnique = "false";
_newSchema.Group = "false";

_newSchema.IsLockable = "false";
_newSchema.IsDeltaField = "false";
_newSchema.IsPrimaryKey = "false";
_newSchema.FillType = "None";
_newSchema.Direction = "Input";
_newSchema.OverrideFormatting = "false";
_newSchema.ValueSetByDatabase = "false";
_newSchema.FormatScale = "0";
_newSchema.NegativeFormatting = "Standard";
_newSchema.AggregateFunction = "false";
_newSchema.IsExpression = "false";
_newSchema.IsBrowsable = "true";
_newSchema.IsQueryable = "true";
_newSchema.IsEnumeration = "false";
_newSchema.IsAddInPrimaryKey = "false";
_newSchema.IsExcludedFromReset = "false";
_newSchema.IsMember = "false";
_newSchema.AddInTableName = "";


_newObject.IsCacheable = "false";

_newObject.AllowZeroKeys = "false";
_newObject.TransactionMode = "Required";
_newObject.IsStoredProcedure = "false";
_newObject.ProcedureReturnType = "";
_newFieldList.Add(_newSchema);


_newPersistantObjectList.Add(_newObject);
_newPObject.PersistentObject.AddRange(_newPersistantObjectList);

schemeContent.Text = HelperXml.ToXML(_newPObject);



Example 1.1



 <?xml version="1.0" encoding="utf-8"?>
<ObjectStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:SageObjectStore">
<ApplicationNamespace>BusinessObjects</ApplicationNamespace>
<MemberVariablePrefix>_</MemberVariablePrefix>
<ClassPrefix>Persistent</ClassPrefix>
<ClassSuffix />
<Language>VB</Language>
<Path>C:Sage200SchemaExtensions</Path>
<GenerateBusinessObjects>false</GenerateBusinessObjects>
<GenerateSeparateFiles>false</GenerateSeparateFiles>
<PersistentObjects>
<PersistentObject Name="Customer">
<TableName>SLCustomerAccount</TableName>
<Description />
<Fields>
<Field Name="SLCustomerAccountID">
<DbType>Int64</DbType>
<Precision>19</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>true</IsReadOnly>
<AllowOverwrite>Equal</AllowOverwrite>
<IsPrimaryKey>true</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>true</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>true</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>9999999999999999999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>SLCustomer Account ID</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
</Fields>
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<AlwaysAllowPaging>false</AlwaysAllowPaging>
<Namespace>SalesLedger</Namespace>
<PagingFields />
<TransactionMode>Required</TransactionMode>
<IsStoredProcedure>false</IsStoredProcedure>
<ProcedureReturnType />
</PersistentObject>
<PersistentObject Name="MCSSopOrderss">
<TableName />
<Description />
<Fields>
<Field Name="CustomerID">
<DbType>Int64</DbType>
<Precision>11</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>true</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>99999999999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>



<IsExpression>false</IsExpression>
<FriendlyName>Customer ID</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestDate">
<DbType>Date</DbType>
<Precision>3</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>true</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>99/99/9999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>test</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestString">
<DbType>String</DbType>
<Precision>64</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test String</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestMoney">
<UserDataType>MonetaryValue2dp</UserDataType>
<DbType>String</DbType>
<Precision>12</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Money</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestDecimal">
<DbType>Decimal</DbType>
<Precision>18</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>999999999999999999.</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Decimal</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestCurrency">
<DbType>Currency</DbType>
<Precision>11</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<FormatMask>99999999999.99</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Currency</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="Test">
<DbType>String</DbType>
<Precision>64</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
</Fields>
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<AlwaysAllowPaging>false</AlwaysAllowPaging>
<Namespace />
<PagingFields />
<TransactionMode>Required</TransactionMode>
<IsStoredProcedure>false</IsStoredProcedure>
<ProcedureReturnType />
</PersistentObject>
</PersistentObjects>
<Relationships>
<Relationship>
<ParentObject>Customer</ParentObject>
<ParentKey>SLCustomerAccountID</ParentKey>
<ChildObject>MCSSopOrderss</ChildObject>
<ChildKey>CustomerID</ChildKey>
<InsertOperation>CheckParentExists</InsertOperation>
<DeleteOperation>CheckForAnyChildren</DeleteOperation>
<IsOneToMany>true</IsOneToMany>

</Relationship>
</Relationships>
<DataTypes />
<Enumerations />
<BaselineSchema>C:Program Files (x86)Sage 200
SDKSageObjectStore.xml</BaselineSchema>
</ObjectStore>


However what I am getting is the following For that table there is 44 objects in the field list list so for fields it should be printing that and as you can see its ignorning the name property i am setting on persitent object as well.



 <?xml version="1.0" encoding="utf-16"?>
<ObjectStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<PersistentObjects>
<PersistentObject>
<Fields />
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<TransactionMode>Required</TransactionMode>
<ProcedureReturnType />
<IsStoredProcedure>false</IsStoredProcedure>
</PersistentObject>
</PersistentObjects>
<PersistentObject>
<PersistentObject>
<Fields />
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<TransactionMode>Required</TransactionMode>
<ProcedureReturnType />
<IsStoredProcedure>false</IsStoredProcedure>
</PersistentObject>
</PersistentObject>
</ObjectStore>


My Class for the above.



 public class SageXmlDefiniation

public class ObjectStore


public List<PersistentObject> PersistentObjects = new
List<PersistentObject>();
public string ApplicationnameSpace get; set;
public string MemberVariablePrefix get; set;
public string ClassPrefix get; set;
public string ClassSuffix get; set;
public string Language get; set;
public string Path get; set;
public string GenerateBusinessObjects get; set;
public string GenerateSeparateFiles get; set;

public List<PersistentObject> PersistentObject

get return PersistentObjects;
set PersistentObjects = value;



public class PersistentObject

private List<FieldSchemaXml> _Fields = new List<FieldSchemaXml>();

[XmlAttribute("Name")]
public string Name get; set;

public string TableName get; set;
public string Description get; set;
[XmlArray("Fields")]
[XmlArrayItem("Field")]
public List<FieldSchemaXml> FieldsList

get return _Fields;
set _Fields = value;

public string IsCacheable get; set;
public string AllowZeroKeys get; set;
public string NameSapce get; set;

public string PagingFields get; set;
public string TransactionMode get; set;
public string ProcedureReturnType get; set;
public string IsStoredProcedure get; set;

public class FieldSchemaXml

[XmlAttribute("Name")]
public string Name get; set;

public string DBType get; set;
public string Precision get; set;
public string Scale get; set;
public string FillType get; set;
public string IsNullable get; set;
public string IsReadOnly get; set;
public string AllowOverwrite get; set;
public string IsPrimaryKey get; set;

public string IsDeltaField get; set;
public string IsIndexed get; set;
public string IsTransient get; set;
public string IsUnique get; set;

public string OverrideFormatting get; set;
public string IsLockable get; set;
public string Direction get; set;
public string ValueSetByDatabase get; set;
public string FormatScale get; set;
public string FormatMask get; set;
public string NegativeFormatting get; set;
public string Group get; set;
public string AggregateFunction get; set;
public string IsExcludedFromCopy get; set;
public string IsExpression get; set;
public string FriendlyName get; set;
public string IsBrowsable get; set;
public string IsQueryable get; set;
public string IsEnumeration get; set;

public string IsAddInPrimaryKey get; set;
public string AddInTableName get; set;
public string AddInRelationField get; set;
public string IsMember get; set;
public string IsExcludedFromReset get; set;






My code which returns correct 44 fields for the above table.



public List<TableDefnition> GetALLTableDeiniations(string tableName)

string sql = @"SELECT c.name Field,
t.name Type,
c.max_length MaxLength,
c.Precision,
c.Scale,
c.is_nullable,
c.collation_name
FROM sys.columns c
INNER JOIN sys.types t ON t.system_type_id = c.system_type_id
WHERE object_id = object_id('"+ tableName + "') ORDER BY column_id";

using (var connection = new
sqlConnection(ConfigurationManager.AppSettings["ConnectionString"]))

List<TableDefnition> _tableDefnitions = connection.Query<TableDefnition>(sql).ToList();
return _tableDefnitions;












share|improve this question






















  • I don't see anywhere you set a Name on PersistentObject (which is _newObject). I don't see anywhere you set or add to the FieldsList either.

    – Charles Mager
    Mar 24 at 18:22














0












0








0








I am trying to build a schema xml using the following but I am having issues items our being repeated twice and the fields are not being populated.



Basically what happens is the program goes out to sql gets the columns names of the chosen tables then it should produce a schema simlar to as follows not identically in term of values but yes in terms of structure



 public List<TableNames> _tablesNamesList = new List<TableNames>();

public void BuildSchema()


foreach (var table in _tablesNamesList)

PersistentObject _newObject = new PersistentObject();
List<PersistentObject> _newPersistantObjectList = new List<PersistentObject>();

List<TableDefnition> _newList = db.GetALLTableDeiniations(table.TABLE_NAME);

List<FieldSchemaXml> _newFieldList = new List<FieldSchemaXml>();


foreach (var item in _newList)


FieldSchemaXml _newSchema = new FieldSchemaXml();


_newSchema = ConvertSQLDataTypeToSage(item.Type, _newSchema, item);


_newSchema.Name = item.Field;
_newSchema.IsUnique = "false";
_newSchema.IsReadOnly = "false";
_newSchema.IsQueryable = "true";
if (item.is_nullable == 1)


_newSchema.IsNullable = "true";

else

_newSchema.IsNullable = "false";


_newSchema.IsReadOnly = "false";
_newSchema.IsUnique = "false";
_newSchema.Group = "false";

_newSchema.IsLockable = "false";
_newSchema.IsDeltaField = "false";
_newSchema.IsPrimaryKey = "false";
_newSchema.FillType = "None";
_newSchema.Direction = "Input";
_newSchema.OverrideFormatting = "false";
_newSchema.ValueSetByDatabase = "false";
_newSchema.FormatScale = "0";
_newSchema.NegativeFormatting = "Standard";
_newSchema.AggregateFunction = "false";
_newSchema.IsExpression = "false";
_newSchema.IsBrowsable = "true";
_newSchema.IsQueryable = "true";
_newSchema.IsEnumeration = "false";
_newSchema.IsAddInPrimaryKey = "false";
_newSchema.IsExcludedFromReset = "false";
_newSchema.IsMember = "false";
_newSchema.AddInTableName = "";


_newObject.IsCacheable = "false";

_newObject.AllowZeroKeys = "false";
_newObject.TransactionMode = "Required";
_newObject.IsStoredProcedure = "false";
_newObject.ProcedureReturnType = "";
_newFieldList.Add(_newSchema);


_newPersistantObjectList.Add(_newObject);
_newPObject.PersistentObject.AddRange(_newPersistantObjectList);

schemeContent.Text = HelperXml.ToXML(_newPObject);



Example 1.1



 <?xml version="1.0" encoding="utf-8"?>
<ObjectStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:SageObjectStore">
<ApplicationNamespace>BusinessObjects</ApplicationNamespace>
<MemberVariablePrefix>_</MemberVariablePrefix>
<ClassPrefix>Persistent</ClassPrefix>
<ClassSuffix />
<Language>VB</Language>
<Path>C:Sage200SchemaExtensions</Path>
<GenerateBusinessObjects>false</GenerateBusinessObjects>
<GenerateSeparateFiles>false</GenerateSeparateFiles>
<PersistentObjects>
<PersistentObject Name="Customer">
<TableName>SLCustomerAccount</TableName>
<Description />
<Fields>
<Field Name="SLCustomerAccountID">
<DbType>Int64</DbType>
<Precision>19</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>true</IsReadOnly>
<AllowOverwrite>Equal</AllowOverwrite>
<IsPrimaryKey>true</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>true</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>true</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>9999999999999999999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>SLCustomer Account ID</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
</Fields>
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<AlwaysAllowPaging>false</AlwaysAllowPaging>
<Namespace>SalesLedger</Namespace>
<PagingFields />
<TransactionMode>Required</TransactionMode>
<IsStoredProcedure>false</IsStoredProcedure>
<ProcedureReturnType />
</PersistentObject>
<PersistentObject Name="MCSSopOrderss">
<TableName />
<Description />
<Fields>
<Field Name="CustomerID">
<DbType>Int64</DbType>
<Precision>11</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>true</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>99999999999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>



<IsExpression>false</IsExpression>
<FriendlyName>Customer ID</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestDate">
<DbType>Date</DbType>
<Precision>3</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>true</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>99/99/9999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>test</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestString">
<DbType>String</DbType>
<Precision>64</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test String</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestMoney">
<UserDataType>MonetaryValue2dp</UserDataType>
<DbType>String</DbType>
<Precision>12</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Money</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestDecimal">
<DbType>Decimal</DbType>
<Precision>18</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>999999999999999999.</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Decimal</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestCurrency">
<DbType>Currency</DbType>
<Precision>11</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<FormatMask>99999999999.99</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Currency</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="Test">
<DbType>String</DbType>
<Precision>64</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
</Fields>
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<AlwaysAllowPaging>false</AlwaysAllowPaging>
<Namespace />
<PagingFields />
<TransactionMode>Required</TransactionMode>
<IsStoredProcedure>false</IsStoredProcedure>
<ProcedureReturnType />
</PersistentObject>
</PersistentObjects>
<Relationships>
<Relationship>
<ParentObject>Customer</ParentObject>
<ParentKey>SLCustomerAccountID</ParentKey>
<ChildObject>MCSSopOrderss</ChildObject>
<ChildKey>CustomerID</ChildKey>
<InsertOperation>CheckParentExists</InsertOperation>
<DeleteOperation>CheckForAnyChildren</DeleteOperation>
<IsOneToMany>true</IsOneToMany>

</Relationship>
</Relationships>
<DataTypes />
<Enumerations />
<BaselineSchema>C:Program Files (x86)Sage 200
SDKSageObjectStore.xml</BaselineSchema>
</ObjectStore>


However what I am getting is the following For that table there is 44 objects in the field list list so for fields it should be printing that and as you can see its ignorning the name property i am setting on persitent object as well.



 <?xml version="1.0" encoding="utf-16"?>
<ObjectStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<PersistentObjects>
<PersistentObject>
<Fields />
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<TransactionMode>Required</TransactionMode>
<ProcedureReturnType />
<IsStoredProcedure>false</IsStoredProcedure>
</PersistentObject>
</PersistentObjects>
<PersistentObject>
<PersistentObject>
<Fields />
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<TransactionMode>Required</TransactionMode>
<ProcedureReturnType />
<IsStoredProcedure>false</IsStoredProcedure>
</PersistentObject>
</PersistentObject>
</ObjectStore>


My Class for the above.



 public class SageXmlDefiniation

public class ObjectStore


public List<PersistentObject> PersistentObjects = new
List<PersistentObject>();
public string ApplicationnameSpace get; set;
public string MemberVariablePrefix get; set;
public string ClassPrefix get; set;
public string ClassSuffix get; set;
public string Language get; set;
public string Path get; set;
public string GenerateBusinessObjects get; set;
public string GenerateSeparateFiles get; set;

public List<PersistentObject> PersistentObject

get return PersistentObjects;
set PersistentObjects = value;



public class PersistentObject

private List<FieldSchemaXml> _Fields = new List<FieldSchemaXml>();

[XmlAttribute("Name")]
public string Name get; set;

public string TableName get; set;
public string Description get; set;
[XmlArray("Fields")]
[XmlArrayItem("Field")]
public List<FieldSchemaXml> FieldsList

get return _Fields;
set _Fields = value;

public string IsCacheable get; set;
public string AllowZeroKeys get; set;
public string NameSapce get; set;

public string PagingFields get; set;
public string TransactionMode get; set;
public string ProcedureReturnType get; set;
public string IsStoredProcedure get; set;

public class FieldSchemaXml

[XmlAttribute("Name")]
public string Name get; set;

public string DBType get; set;
public string Precision get; set;
public string Scale get; set;
public string FillType get; set;
public string IsNullable get; set;
public string IsReadOnly get; set;
public string AllowOverwrite get; set;
public string IsPrimaryKey get; set;

public string IsDeltaField get; set;
public string IsIndexed get; set;
public string IsTransient get; set;
public string IsUnique get; set;

public string OverrideFormatting get; set;
public string IsLockable get; set;
public string Direction get; set;
public string ValueSetByDatabase get; set;
public string FormatScale get; set;
public string FormatMask get; set;
public string NegativeFormatting get; set;
public string Group get; set;
public string AggregateFunction get; set;
public string IsExcludedFromCopy get; set;
public string IsExpression get; set;
public string FriendlyName get; set;
public string IsBrowsable get; set;
public string IsQueryable get; set;
public string IsEnumeration get; set;

public string IsAddInPrimaryKey get; set;
public string AddInTableName get; set;
public string AddInRelationField get; set;
public string IsMember get; set;
public string IsExcludedFromReset get; set;






My code which returns correct 44 fields for the above table.



public List<TableDefnition> GetALLTableDeiniations(string tableName)

string sql = @"SELECT c.name Field,
t.name Type,
c.max_length MaxLength,
c.Precision,
c.Scale,
c.is_nullable,
c.collation_name
FROM sys.columns c
INNER JOIN sys.types t ON t.system_type_id = c.system_type_id
WHERE object_id = object_id('"+ tableName + "') ORDER BY column_id";

using (var connection = new
sqlConnection(ConfigurationManager.AppSettings["ConnectionString"]))

List<TableDefnition> _tableDefnitions = connection.Query<TableDefnition>(sql).ToList();
return _tableDefnitions;












share|improve this question














I am trying to build a schema xml using the following but I am having issues items our being repeated twice and the fields are not being populated.



Basically what happens is the program goes out to sql gets the columns names of the chosen tables then it should produce a schema simlar to as follows not identically in term of values but yes in terms of structure



 public List<TableNames> _tablesNamesList = new List<TableNames>();

public void BuildSchema()


foreach (var table in _tablesNamesList)

PersistentObject _newObject = new PersistentObject();
List<PersistentObject> _newPersistantObjectList = new List<PersistentObject>();

List<TableDefnition> _newList = db.GetALLTableDeiniations(table.TABLE_NAME);

List<FieldSchemaXml> _newFieldList = new List<FieldSchemaXml>();


foreach (var item in _newList)


FieldSchemaXml _newSchema = new FieldSchemaXml();


_newSchema = ConvertSQLDataTypeToSage(item.Type, _newSchema, item);


_newSchema.Name = item.Field;
_newSchema.IsUnique = "false";
_newSchema.IsReadOnly = "false";
_newSchema.IsQueryable = "true";
if (item.is_nullable == 1)


_newSchema.IsNullable = "true";

else

_newSchema.IsNullable = "false";


_newSchema.IsReadOnly = "false";
_newSchema.IsUnique = "false";
_newSchema.Group = "false";

_newSchema.IsLockable = "false";
_newSchema.IsDeltaField = "false";
_newSchema.IsPrimaryKey = "false";
_newSchema.FillType = "None";
_newSchema.Direction = "Input";
_newSchema.OverrideFormatting = "false";
_newSchema.ValueSetByDatabase = "false";
_newSchema.FormatScale = "0";
_newSchema.NegativeFormatting = "Standard";
_newSchema.AggregateFunction = "false";
_newSchema.IsExpression = "false";
_newSchema.IsBrowsable = "true";
_newSchema.IsQueryable = "true";
_newSchema.IsEnumeration = "false";
_newSchema.IsAddInPrimaryKey = "false";
_newSchema.IsExcludedFromReset = "false";
_newSchema.IsMember = "false";
_newSchema.AddInTableName = "";


_newObject.IsCacheable = "false";

_newObject.AllowZeroKeys = "false";
_newObject.TransactionMode = "Required";
_newObject.IsStoredProcedure = "false";
_newObject.ProcedureReturnType = "";
_newFieldList.Add(_newSchema);


_newPersistantObjectList.Add(_newObject);
_newPObject.PersistentObject.AddRange(_newPersistantObjectList);

schemeContent.Text = HelperXml.ToXML(_newPObject);



Example 1.1



 <?xml version="1.0" encoding="utf-8"?>
<ObjectStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:SageObjectStore">
<ApplicationNamespace>BusinessObjects</ApplicationNamespace>
<MemberVariablePrefix>_</MemberVariablePrefix>
<ClassPrefix>Persistent</ClassPrefix>
<ClassSuffix />
<Language>VB</Language>
<Path>C:Sage200SchemaExtensions</Path>
<GenerateBusinessObjects>false</GenerateBusinessObjects>
<GenerateSeparateFiles>false</GenerateSeparateFiles>
<PersistentObjects>
<PersistentObject Name="Customer">
<TableName>SLCustomerAccount</TableName>
<Description />
<Fields>
<Field Name="SLCustomerAccountID">
<DbType>Int64</DbType>
<Precision>19</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>true</IsReadOnly>
<AllowOverwrite>Equal</AllowOverwrite>
<IsPrimaryKey>true</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>true</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>true</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>9999999999999999999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>SLCustomer Account ID</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
</Fields>
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<AlwaysAllowPaging>false</AlwaysAllowPaging>
<Namespace>SalesLedger</Namespace>
<PagingFields />
<TransactionMode>Required</TransactionMode>
<IsStoredProcedure>false</IsStoredProcedure>
<ProcedureReturnType />
</PersistentObject>
<PersistentObject Name="MCSSopOrderss">
<TableName />
<Description />
<Fields>
<Field Name="CustomerID">
<DbType>Int64</DbType>
<Precision>11</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>true</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>99999999999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>



<IsExpression>false</IsExpression>
<FriendlyName>Customer ID</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestDate">
<DbType>Date</DbType>
<Precision>3</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>true</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>99/99/9999</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>test</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestString">
<DbType>String</DbType>
<Precision>64</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test String</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestMoney">
<UserDataType>MonetaryValue2dp</UserDataType>
<DbType>String</DbType>
<Precision>12</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Money</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestDecimal">
<DbType>Decimal</DbType>
<Precision>18</Precision>
<Scale>0</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>0</FormatScale>
<FormatMask>999999999999999999.</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Decimal</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="TestCurrency">
<DbType>Currency</DbType>
<Precision>11</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<FormatMask>99999999999.99</FormatMask>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test Currency</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
<Field Name="Test">
<DbType>String</DbType>
<Precision>64</Precision>
<Scale>2</Scale>
<FillType>None</FillType>
<IsNullable>false</IsNullable>
<IsReadOnly>false</IsReadOnly>
<AllowOverwrite>True</AllowOverwrite>
<IsPrimaryKey>false</IsPrimaryKey>
<IsDeltaField>false</IsDeltaField>
<IsIndexed>false</IsIndexed>
<IsTransient>false</IsTransient>
<IsUnique>false</IsUnique>
<OverrideFormatting>false</OverrideFormatting>
<IsLockable>false</IsLockable>
<Direction>Input</Direction>
<ValueSetByDatabase>false</ValueSetByDatabase>
<FormatScale>2</FormatScale>
<NegativeFormatting>Standard</NegativeFormatting>
<Group>false</Group>
<AggregateFunction>None</AggregateFunction>
<IsExcludedFromCopy>false</IsExcludedFromCopy>
<IsExpression>false</IsExpression>
<FriendlyName>Test</FriendlyName>
<IsBrowsable>true</IsBrowsable>
<IsQueryable>true</IsQueryable>
<IsEnumeration>false</IsEnumeration>
<IsAddInPrimaryKey>false</IsAddInPrimaryKey>
<AddInTableName />
<AddInRelationField />
<IsMember>false</IsMember>
<IsExcludedFromReset>false</IsExcludedFromReset>
</Field>
</Fields>
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<AlwaysAllowPaging>false</AlwaysAllowPaging>
<Namespace />
<PagingFields />
<TransactionMode>Required</TransactionMode>
<IsStoredProcedure>false</IsStoredProcedure>
<ProcedureReturnType />
</PersistentObject>
</PersistentObjects>
<Relationships>
<Relationship>
<ParentObject>Customer</ParentObject>
<ParentKey>SLCustomerAccountID</ParentKey>
<ChildObject>MCSSopOrderss</ChildObject>
<ChildKey>CustomerID</ChildKey>
<InsertOperation>CheckParentExists</InsertOperation>
<DeleteOperation>CheckForAnyChildren</DeleteOperation>
<IsOneToMany>true</IsOneToMany>

</Relationship>
</Relationships>
<DataTypes />
<Enumerations />
<BaselineSchema>C:Program Files (x86)Sage 200
SDKSageObjectStore.xml</BaselineSchema>
</ObjectStore>


However what I am getting is the following For that table there is 44 objects in the field list list so for fields it should be printing that and as you can see its ignorning the name property i am setting on persitent object as well.



 <?xml version="1.0" encoding="utf-16"?>
<ObjectStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<PersistentObjects>
<PersistentObject>
<Fields />
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<TransactionMode>Required</TransactionMode>
<ProcedureReturnType />
<IsStoredProcedure>false</IsStoredProcedure>
</PersistentObject>
</PersistentObjects>
<PersistentObject>
<PersistentObject>
<Fields />
<IsCacheable>false</IsCacheable>
<AllowZeroKeys>false</AllowZeroKeys>
<TransactionMode>Required</TransactionMode>
<ProcedureReturnType />
<IsStoredProcedure>false</IsStoredProcedure>
</PersistentObject>
</PersistentObject>
</ObjectStore>


My Class for the above.



 public class SageXmlDefiniation

public class ObjectStore


public List<PersistentObject> PersistentObjects = new
List<PersistentObject>();
public string ApplicationnameSpace get; set;
public string MemberVariablePrefix get; set;
public string ClassPrefix get; set;
public string ClassSuffix get; set;
public string Language get; set;
public string Path get; set;
public string GenerateBusinessObjects get; set;
public string GenerateSeparateFiles get; set;

public List<PersistentObject> PersistentObject

get return PersistentObjects;
set PersistentObjects = value;



public class PersistentObject

private List<FieldSchemaXml> _Fields = new List<FieldSchemaXml>();

[XmlAttribute("Name")]
public string Name get; set;

public string TableName get; set;
public string Description get; set;
[XmlArray("Fields")]
[XmlArrayItem("Field")]
public List<FieldSchemaXml> FieldsList

get return _Fields;
set _Fields = value;

public string IsCacheable get; set;
public string AllowZeroKeys get; set;
public string NameSapce get; set;

public string PagingFields get; set;
public string TransactionMode get; set;
public string ProcedureReturnType get; set;
public string IsStoredProcedure get; set;

public class FieldSchemaXml

[XmlAttribute("Name")]
public string Name get; set;

public string DBType get; set;
public string Precision get; set;
public string Scale get; set;
public string FillType get; set;
public string IsNullable get; set;
public string IsReadOnly get; set;
public string AllowOverwrite get; set;
public string IsPrimaryKey get; set;

public string IsDeltaField get; set;
public string IsIndexed get; set;
public string IsTransient get; set;
public string IsUnique get; set;

public string OverrideFormatting get; set;
public string IsLockable get; set;
public string Direction get; set;
public string ValueSetByDatabase get; set;
public string FormatScale get; set;
public string FormatMask get; set;
public string NegativeFormatting get; set;
public string Group get; set;
public string AggregateFunction get; set;
public string IsExcludedFromCopy get; set;
public string IsExpression get; set;
public string FriendlyName get; set;
public string IsBrowsable get; set;
public string IsQueryable get; set;
public string IsEnumeration get; set;

public string IsAddInPrimaryKey get; set;
public string AddInTableName get; set;
public string AddInRelationField get; set;
public string IsMember get; set;
public string IsExcludedFromReset get; set;






My code which returns correct 44 fields for the above table.



public List<TableDefnition> GetALLTableDeiniations(string tableName)

string sql = @"SELECT c.name Field,
t.name Type,
c.max_length MaxLength,
c.Precision,
c.Scale,
c.is_nullable,
c.collation_name
FROM sys.columns c
INNER JOIN sys.types t ON t.system_type_id = c.system_type_id
WHERE object_id = object_id('"+ tableName + "') ORDER BY column_id";

using (var connection = new
sqlConnection(ConfigurationManager.AppSettings["ConnectionString"]))

List<TableDefnition> _tableDefnitions = connection.Query<TableDefnition>(sql).ToList();
return _tableDefnitions;









c# xml xml-serialization






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 17:10









DaveDave

989




989












  • I don't see anywhere you set a Name on PersistentObject (which is _newObject). I don't see anywhere you set or add to the FieldsList either.

    – Charles Mager
    Mar 24 at 18:22


















  • I don't see anywhere you set a Name on PersistentObject (which is _newObject). I don't see anywhere you set or add to the FieldsList either.

    – Charles Mager
    Mar 24 at 18:22

















I don't see anywhere you set a Name on PersistentObject (which is _newObject). I don't see anywhere you set or add to the FieldsList either.

– Charles Mager
Mar 24 at 18:22






I don't see anywhere you set a Name on PersistentObject (which is _newObject). I don't see anywhere you set or add to the FieldsList either.

– Charles Mager
Mar 24 at 18:22













0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55326354%2fxml-not-matching-expected-results%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55326354%2fxml-not-matching-expected-results%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript