Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Entity-DB mapping and Entity attributes from XML file (vs. POCO attributes) #16

Open
marcguyboyer opened this issue Aug 7, 2016 · 0 comments

Comments

@marcguyboyer
Copy link

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

@MaceWindu MaceWindu transferred this issue from linq2db/linq2db May 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant