This question is locked. New answers and comments are not allowed.
Hi, I'm trying to add an artificial field to a persistent class at runtime.
Since the persistent class resides in a class library, I'm using a XML approach to create a Database instance like this:
Although I'm expecting that a field "age" of type String is added to Softgate.Stratus.Data.BarData class, it doesn't work like that way. I noticed that CreateUpdateDDLScript method is simply returning a null.
For your information, the above code fragment is basically working fine except the artificial field creation. It seems that those connection.Append lines, that are meant to deal with the artificial field, don't have effect at all.
Any comment and/or example would be very appreciated. Thanks in advance.
Since the persistent class resides in a class library, I'm using a XML approach to create a Database instance like this:
String assumedInitialConfiguration = |
"<openaccess>" + |
"<references>" + |
"<reference assemblyname='PLACEHOLDER' configrequired='True'/>" + |
"</references>" + |
"{0}" + |
"</openaccess>"; |
StringBuilder connection = new StringBuilder(); |
connection.Append("<artificial>"); |
connection.Append("<mapping id=\"artificialMapping\">"); |
connection.Append("<namespace name=\"Softgate.Stratus.Data\">"); |
connection.Append("<class name=\"BarData\">"); |
connection.Append("<field name=\"age\" clr=\"System.String\"/>"); |
connection.Append("</class>"); |
connection.Append("</namespace>"); |
connection.Append("</mapping>"); |
connection.Append("</artificial>"); |
System.Reflection.Assembly dll = theObjectScopeProvider.GetType().Assembly; |
assumedInitialConfiguration = assumedInitialConfiguration.Replace("PLACEHOLDER", dll.GetName().Name); |
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); |
xmlDoc.LoadXml(String.Format(assumedInitialConfiguration, connection.ToString())); |
Database db = Telerik.OpenAccess.Database.Get("StratusConnection", xmlDoc.DocumentElement, new System.Reflection.Assembly[] { dll }); |
string ddlscript = db.GetSchemaHandler().CreateUpdateDDLScript(null); |
if (!string.IsNullOrEmpty(ddlscript)) |
db.GetSchemaHandler().ExecuteDDLScript(ddlscript); |
Although I'm expecting that a field "age" of type String is added to Softgate.Stratus.Data.BarData class, it doesn't work like that way. I noticed that CreateUpdateDDLScript method is simply returning a null.
For your information, the above code fragment is basically working fine except the artificial field creation. It seems that those connection.Append lines, that are meant to deal with the artificial field, don't have effect at all.
Any comment and/or example would be very appreciated. Thanks in advance.