This question is locked. New answers and comments are not allowed.
Hello,
i want to extend my existing Model (rlinq) at runtime with new tables.
For that i have a tabledefinition-file where i can define the needed structure of the existing tables.
For example like following:
This File is parsed at runtime and should extend my modell so that i can access this tables in the database.
Something like the following...
The Modell is expanded and i can see under the metadata.PersistentTypes my new defined Tables.
But if i want to query it i get an error: No persistent type with the given name found.
The value of the used sHeadTable variable is for example: TestNamespace.com_generic_head
This value is also shown under the metadata.PersistentTypes.
If i exchange the name of the table in the fluentContext.Scope.ExtentByName function with a tablename which was allready in the modell at designtime, the function succeeds.
The Table property under the metadata.PersistentType does not show a name...only MetaTable: "" 4 columns.
The PersistentTypes which are exists since designtime show for example MetaTable "'COM'.'PDHEAD'" 109 columns
What i am missing to bind the mapping to the real table in the database?
Is there any smal example code how to do?
i want to extend my existing Model (rlinq) at runtime with new tables.
For that i have a tabledefinition-file where i can define the needed structure of the existing tables.
For example like following:
# Example of a table definition file used for generic xml-export TABLESTART(com_generic_head,TestNamespace) PROPERTY(field1,STRING,KEY) PROPERTY(field2,DECIMAL) PROPERTY(field3,DATE) PROPERTY(field4,INT) TABLEEND TABLESTART(com_generic_child1,TestNamespace) PROPERTY(child_s_key,STRING,KEY) PROPERTY(child_s_head_key,STRING) PROPERTY(field1,INT) PROPERTY(field2,STRING) TABLEEND Something like the following...
public class MyFluentMetadataSource : FluentMetadataSource { private string sTDFile = ""; public MyFluentMetadataSource() { } public MyFluentMetadataSource(string sTableDefinitionFile, MetadataContainer existingModel) : base(existingModel) { sTDFile = sTableDefinitionFile; } protected override IList<MappingConfiguration> PrepareMapping() { IList<MappingConfiguration> preparedConfigurations = new List<MappingConfiguration>(); if (sTDFile != "") { using (StreamReader r = new StreamReader(sTDFile)) { ...Parsing File and create mappings... MappingConfiguration newConfiguration = null; newConfiguration = new MappingConfiguration(tableName, nameSpace); newConfiguration.HasArtificialStringProperty(fieldName); .... preparedConfigurations.Add(newConfiguration); } } return preparedConfigurations; } The Modell is expanded and i can see under the metadata.PersistentTypes my new defined Tables.
But if i want to query it i get an error: No persistent type with the given name found.
The value of the used sHeadTable variable is for example: TestNamespace.com_generic_head
This value is also shown under the metadata.PersistentTypes.
IQueryable<PersistenceCapable> query = fluentContext.Scope.ExtentByName(theDefinitionSet.sHeadTable) as IQueryable<PersistenceCapable>; foreach (PersistenceCapable instance in query) {
string s = instance.FieldValue<string>("field1");
... If i exchange the name of the table in the fluentContext.Scope.ExtentByName function with a tablename which was allready in the modell at designtime, the function succeeds.
The Table property under the metadata.PersistentType does not show a name...only MetaTable: "" 4 columns.
The PersistentTypes which are exists since designtime show for example MetaTable "'COM'.'PDHEAD'" 109 columns
What i am missing to bind the mapping to the real table in the database?
Is there any smal example code how to do?