You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am preparing to use linq2db in a project. The Wiki gives an example of how to annotate a POCO class to build the Entity-DB mapping necessary to generate usable SQL for LINQ expression tree. However, I would like to load these attributes from an XML file instead - to avoid mixing DB and Entity specification. This will leave the POCO code clean. But linq2db will still have what it needs to do the SQL generation.
LinqToDB.Metadata.XmlAttributeReader looks like it will fit the bill, and there is sample XML in the Tests.Metada.XmlReaderTests.cs file. However, I'm not confident that I could write up XML that would work first-time with linq2db. I am also not certain how to apply the loaded mapping so that linq2db uses it (instead of trying to use reflection to analyse the POCO types).
Would you have a minute to post: a) a sample XML file that shows the key attributes that might be applied to a POCO class and its members; b) how to initialize linq2db so that this model is used, and not the one generated by reflection - which won't work if I don't annotate the POCO class with the various attributes.
I did notice that you also have a tool to generate the annotated POCO classes from a model (DB or otherwise). However, again, my hope is to keep the entity-DB mapping and entity attributes in an XML file, to keep the POCO sparse. Thank you!
Marc
The text was updated successfully, but these errors were encountered:
Hi Igor,
I am preparing to use linq2db in a project. The Wiki gives an example of how to annotate a POCO class to build the Entity-DB mapping necessary to generate usable SQL for LINQ expression tree. However, I would like to load these attributes from an XML file instead - to avoid mixing DB and Entity specification. This will leave the POCO code clean. But linq2db will still have what it needs to do the SQL generation.
LinqToDB.Metadata.XmlAttributeReader looks like it will fit the bill, and there is sample XML in the Tests.Metada.XmlReaderTests.cs file. However, I'm not confident that I could write up XML that would work first-time with linq2db. I am also not certain how to apply the loaded mapping so that linq2db uses it (instead of trying to use reflection to analyse the POCO types).
Would you have a minute to post: a) a sample XML file that shows the key attributes that might be applied to a POCO class and its members; b) how to initialize linq2db so that this model is used, and not the one generated by reflection - which won't work if I don't annotate the POCO class with the various attributes.
I did notice that you also have a tool to generate the annotated POCO classes from a model (DB or otherwise). However, again, my hope is to keep the entity-DB mapping and entity attributes in an XML file, to keep the POCO sparse. Thank you!
Marc
The text was updated successfully, but these errors were encountered: