We currently use sp’s and udf’s to generate an XML document that is sent via web service to the client for consumption. I have used an ORM (Entity and Open Access) before but I alway interacted directly with a single class (table). If I had data that needed to goto multiple tables I would break it apart in code and just update the ORM class (table) the data belonged to.
I am wondering if I can get a bit more complicated. Can I somehow create a complex object in the ORM that is an aggregate of all these fields. In other words I would pass to the constructor of my complex orm object the record key desired. The object would then gather from all the tables the needed info and return to me the object…..which I could then serialize into xml and send on it’s way.
I understand that somewhere in the ORM or the DB I have to have the logic to gather all the pieces together so really just looking for input.
If I want an object comprised of data from multiple tables I just add all the tables to the .edmx file. From there I can create a class that gets whatever I want. There’s no need for a 1:1 pairing. Within my method to create the object based on say the primary key from
TableAyou can just do;To save some changes;
Of course these will need some error handling I haven’t included but the concept isn’t that different from when you have the standard EntityObject<->Table mapping. I think it’s simpler to keep some of the normal mapping then build your class on top of it.