I have a web application where i want my users to dynamically create a type…i can do this using reflection but i am not sure of how to persist that type using Entity framework
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Once again – whether this approach is applicable or not (and in any case it is a workaround), depends on your scenario. However, what you can do is serialize your object and store it in a database field. You can basically serialize into any format (binary, json, xml, …).
Note: when using the
xmldatatype you can actually query for the data inside the object (not sure if you can do that directly with EF, but you can always write an SP and call it with EF). See this link for an example.Here is an overview of Storing serialized objects in SQL Server.
Here is an implementation of an XML serializer. You can use it to serialize your object into a string before assigning it to your entities property.