Save and restore type (not object) created at runtime?

paiswifintio

New Member
Inside our application (C# - .NET 4.5) we have a report generation tool. This tool must receive only the SQL command, verify it and from that, create a whole new report with available fields with the same name as specified by the SQL command and corresponding data types, similar to what an ORM tool would do.Because of the nature of this tool we're using Reflection and Emit to create a whole new class. From fields provided by a dataReader (\[code\]System.Data.SqlClient.SqlDataReader\[/code\]) we can create the type and populate it with the corresponding data.The result of this is a IQueryable object that I can use on my reports.This whole process is done and tested but to keep both the report, the generated class and the SQL command together we need to save this new type on the database and because or our database layout and system definitions, this requires me to provide an XML-like file or string to a method that will compress and convert to a Base64 string before saving it.It would be a simple task if I were to save the report into a DLL file, just like shown HERE.But since this new type must be transformed into an XML-like format I'm a little bit lost in here.I have done the opposite on the past: fully create a type from an pure XML file, manually. I also know that I can do something similar but it would require me to loop into every detail/property/method/member/etc of the class to create the XML file.Is there any way (like a helper from .NET framework) that could help me here?
Instead of doing it 100% manually I'd like to delegate the XML generation/parse to a tool probably with a better perforance too...Edit:People, READ THE TITLE BEFORE POSTING COMMENTS! I'm trying to save an XML for the type. TYPE. Not the object. The type.@Mark GravellThanks for the tip. I'll check that.But about the schema: any way to save/load it automatically?
 
Back
Top