terryc_ms

Hello,

I have an existing database which exposes objects in XML form to the existing middle tier. I'd like to know if there is any way to take advantage of the EDM mapping using xml return from a proc

Also, in many cases we package parent/child objects together in xml and send this xml to a proc, so that the transaction is handled efficiently (one trip to the DB and the DB is able to handle the transaction efficiently when we do not marshalled the tran from the middle tier). Is there a way to accomplish this using EF (passing several entities from the object graph into a single proc in the DB)

Thanks




Re: ADO.NET (Pre-release) Map Stored Proc XML output/input parms to EDM entities?

Colin Meek - Microsoft

In this release, the Entity Framework treats XML data as opaque which limits your options to some extent. To query properties of an XML entity, there is a trick you can use with the "DefiningQuery" EntitySet attribute in the SSDL: shred the XML content to make it look like a simple relational table, and then map this virtual table to a CSDL entity set. Of course, this approach only works if the XML data can be reshaped as a relation or set of relations.

A similar strategy can be applied for updates. The Entity Framework cannot package an object graph (or interpret the meaning of a package you provide), but you can invoke a stored procedure with an arbitrary payload and tell the state manager about the results by "Accept"ing changes on the entities processed by the operation.

Thanks,

-Colin






Re: ADO.NET (Pre-release) Map Stored Proc XML output/input parms to EDM entities?

terryc_ms

Thanks Colin, that is interesting... Would that work for a hierarchical set of objects in XML (i.e. if the xml contained order(s) with orderlineitems)


I don't suppose you'd have an example of the get/set that you describe If so it would save me some time (can't hurt to ask). Smile

Thanks!






Re: ADO.NET (Pre-release) Map Stored Proc XML output/input parms to EDM entities?

Daniel Simmons - MSFT

The basic (but unfortunately unhelpful) answer is that you ought to be able to do something like you are thinking where XML is used for a hierarchy of objects both on the way into the database with sprocs and on the way out with defining queries or the like, but the truth of the matter is that this would be quite complicated, and it's not something we have samples of. Sorry.

If you do put something together like this, though, we'd certainly love to hear about it. ;-)

- Danny






Re: ADO.NET (Pre-release) Map Stored Proc XML output/input parms to EDM entities?

terryc_ms

Is there a recommended way to send a hierarchy of changes to the DB one round-trip The performance gain from making one round trip is the primary reason that we are using XML when passing changes in the object graph to the DB.

I'd like to be able to specify that savechanges only sends the properties that have changed to the DB (along with the "key"). We have this ability today by passing XML to/from the DB, and the programmer can control when to update, insert or fail the batch, and then re-load the object graph if necessary in the middle tier. But one problem with using XML is that the XML contract between the C layer and the S layer defines the mapping, eliminating the benefit of the mapping layer in EF.

I'd like to know if there is a way to handle batch type of operations in EF For complex enterprise applications, this type of control is needed (and so using EF in these applications will be limited unless we can accomplish this).

Looking at a related thread (http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2105362&SiteID=1), it looks like the answer is no, but I'd like to get your thoughts on what you recommend for applications that require this level of performance and control over whats in the transaction.






Re: ADO.NET (Pre-release) Map Stored Proc XML output/input parms to EDM entities?

Daniel Simmons - MSFT

First off, you should realize that the EF already does track exactly which properties you change and when it does updates it sends as few properties as possible in the update statements to the database.

That said, though, we do not currently batch updates, and we don't expect in this release to be able to perform the kinds of advanced tuning that you describe where you send an XML document describing changes to several different objects in a hierarchy and then process that on the server in a sproc or something. There are the kinds of things we might do in a future release, but they won't be part of the first release.

Another thing which we expect to do in a future release is support DML queries in addition to the instance based updates we have today. DML queries would make it possible to describe a change that you want made to a set of objects and push that change through the mapping layer so that you can efficiently change a lot of objects at once, etc.

Unfortunately we've got to get through the first steps in this release and then extend the technology over time.

- Danny






Re: ADO.NET (Pre-release) Map Stored Proc XML output/input parms to EDM entities?

terryc_ms

Great thanks - that answers my question.






Re: ADO.NET (Pre-release) Map Stored Proc XML output/input parms to EDM entities?

galloc76

If you guys implemented a way to map into xml fields that would be so awsome. Please think about it...Please...
That would just be so sweet. In the edm designer I could specify an xpath to map to, and the entity layer would take care of all crud stuff automatically.