I need to upgrade an existing DDS-based site on top of the Entity Framework and it uses three different database models from three different databases. And what he needs is a simple addition to the ListDetails page: an XML export button ...
Adding a button is very simple. Creating XML is also not difficult. The task is to get the right table for export, go through all the records and fields and create XML based on any of the 100+ tables in the system!
So, my button calls the export handler (ashx), which generates XML based on the who'se name table that it gets through it. The code I have looks something like this:
Content_CobaEntities Coba = new Content_CobaEntities(); MetadataWorkspace metadataWorkspace = Coba.MetadataWorkspace; EntityContainer container = metadataWorkspace.GetItems<EntityContainer>(DataSpace.CSpace).First(); string namespaceName = metadataWorkspace.GetItems<EntityType>(DataSpace.CSpace).First().NamespaceName; EntitySetBase entitySetBase = container.BaseEntitySets.FirstOrDefault(set => set.ElementType.Name == Entity);
Unfortunately, this only works with one context, and I have three. (But this is the main context.) (In addition, you can use the second parameter to determine the correct context.) And although it allows me to determine the type of entity that you need, it still will not give me access to them. and fields.
So how do I get the data for this object? (Filters are not important; export will return all data.)
And no, no EF4. No .NET 4. This is an older project, VS2008 and cannot be changed to a large number, and it cannot be updated ...
Basically, a query contains two parameters: ContextID and QueryID. ContextID tells me which context to use, and since I have only three different contexts, a simple switch-sol command solves this for me. But one of the contexts contains 60+ queries, each of which is associated with one database table. The Dynamic Data site provides me with the ability to add, edit and delete records from this table, but it needs to be exported in a format that is dictated by my custom code. But with 60 tables, this is too much to write a switch statement for each query, so I need something more general.
source share