New Posts New Posts RSS Feed: 6.0.9 + SaveInterceptor change?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

6.0.9 + SaveInterceptor change?

 Post Reply Post Reply
Author
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Topic: 6.0.9 + SaveInterceptor change?
    Posted: 05-Apr-2011 at 4:09am
Actually I'm not saying there was a change to saveinterceptors, but there was a change to how querying from the server-side works? Or perhaps it would be more correct to say, a change to how certain settings work (or don't) when querying server-side. I need some clarification on the correct usage.
 
When I save a "Deal" it has many navigation properties/children that may or may not have changes, so in the interceptor I need a fully populated Deal + graph. Of course I do not want to lose any possible changes to other entities that are being saved at the same time that are related to this Deal.  Using the Order/Product example, you make a change to the Order, and edit 2 of the products on the order, and add a product, but the Order has 12 products on it. When you save, the Order and 3 Product entities (2 to be updated, 1 to be added) are sent to the Interceptor. On the save you want to fully populate the Order graph while maintaining the edited and new Products for some server-side processing. So...what is the proper query settings to make sure you won't lose anything?
 
Previously I had:
QueryStrategy(FetchStrategy.DataSourceThenCache, MergeStrategy.PreserveChanges) - but this gives an error now (worked in 6.0.7) on the server. I realize the server doesn't so much have a cache...but since some of these entities are already in hand...what are they?
 
I changed it to QueryStrategy(FetchStrategy.DataSourceOnly, MergeStrategy.PreserveChanges) which does not error, but I wanted to be sure that this will work fine with this scenario.
 
Thanks!
Back to Top
robertg View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Mar-2011
Location: California
Posts: 87
Post Options Post Options   Quote robertg Quote  Post ReplyReply Direct Link To This Post Posted: 05-Apr-2011 at 4:16pm
There have been several changes since 6.0.7 that improve data integrity in complex environments. In particular, I wonder if you're now seeing the results of the repair of defect 1660, repaired in 6.0.8 with "The EntityServerSaveInterceptor.OnError method was not receiving concurrency exceptions". Possibly you were in an error state before, but were not able to capture that.

Do you think you could provide some more information, particularly the specific error message you are receiving, and the query which is generating it?

Also, does the same query execute successfully if you are using DataSourceAndCache as your strategy instead of DataSourceOnly? If you have not yet saved your entities before running this query, this would certainly be a better strategy than DataSourceOnly.
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 06-Apr-2011 at 4:12am
The specific error message when using DataSourceAndCache is "Execution of query against the server was successful but execution of query against the local cache failed"
 
And the inner exception on that is "EntityManager.DefaultManager is not available on the server because of threading and security concerns associated with static properties."
 
I make no reference or use of DefaultManager in my code.
 
As far as do I get the same result from the two strategies...I have not taken the time to fully inspect the results. Its not a simple set of objects and so many properties :)
 

IEntityQuery<Deal> q = new EntityQuery<Deal>();
q = (from item in q
.Include(Deal.EntityPropertyNames.BusAssociate)
.Include(Deal.EntityPropertyNames.Deal552Code)
.Include(Deal.EntityPropertyNames.DealCost)
.Include(Deal.EntityPropertyNames.DealPricings)
.Include(Deal.EntityPropertyNames.DealPricings + "." + DealPricing.EntityPropertyNames.DealTrxPricings)
.Include(Deal.EntityPropertyNames.DealTrxes)
.Include(Deal.EntityPropertyNames.DealTrxes + "." + DealTrx.EntityPropertyNames.DealTrxPricings)
.Include(Deal.EntityPropertyNames.Location)
.Include(Deal.EntityPropertyNames.MoContact)
.Include(Deal.EntityPropertyNames.Pipeline)
.Include(Deal.EntityPropertyNames.SupplyContact)
.Include(Deal.EntityPropertyNames.SupplyContract)
.Include(Deal.EntityPropertyNames.Zone)
.Include(Deal.EntityPropertyNames.DealPricings + "." + DealPricing.EntityPropertyNames.IndexLocation)
.Include(Deal.EntityPropertyNames.DealPricings + "." + DealPricing.EntityPropertyNames.IndexPipeline)
.Include(Deal.EntityPropertyNames.DealPricings + "." + DealPricing.EntityPropertyNames.IndexPriceType)
where item.DealId == deal.DealId
select item);
q = q.With(new QueryStrategy(FetchStrategy.DataSourceAndCache, MergeStrategy.PreserveChanges));
 
So in the query of course any direct property could have changed on the Deal, or anything in the DealTrxes, or DealPricings, or DealTrxes.DealTrxPricings - either for this save, or on the database. So the goal is to make sure I have the full graph to perform some further work. This query happens before the save. I have to process the Deal and perform manipulation which will determine what else needs to change before saving. I could have a Deal object and 2 Dealtrxes, and 1 DealPricing all related, all changed and needing saving - but I need to fill in the graph beforehand.
 
On another note - Is there any way to save more then once while in a saveinterceptor? In 6.0.7 I went through several different attempts but short of starting a new process I didn't find a way. Ideally I would like to save at various points in the interceptor but I have a work-around.


Edited by midnit - 06-Apr-2011 at 4:17am
Back to Top
robertg View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Mar-2011
Location: California
Posts: 87
Post Options Post Options   Quote robertg Quote  Post ReplyReply Direct Link To This Post Posted: 11-Apr-2011 at 11:04am
I haven't been able to reproduce your problem, so I suspect it may be due to the complexity of your processing against the entity, and the order in which the operations are being performed. I was wondering if you could do the following:

  • Verify whether or not changing your query strategy to DataSourceAndCache allows you to execute queries successfully and maintain data integrity?
  • Email me (robertg@ideablade.com) a project which has just enough of your code to recreate the problem, preferably using the NorthwindIB database so I can test it and try to find a solution?
  • Email me a DebugLog which shows what is going on when you get this exception?
Thanks,
Robert
Back to Top
robertg View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Mar-2011
Location: California
Posts: 87
Post Options Post Options   Quote robertg Quote  Post ReplyReply Direct Link To This Post Posted: 11-Apr-2011 at 1:06pm
Actually, before doing any of those, you might want to check on the server side and make certain that you're not using a Default Entity Manager for the interceptor.
Back to Top
robertg View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Mar-2011
Location: California
Posts: 87
Post Options Post Options   Quote robertg Quote  Post ReplyReply Direct Link To This Post Posted: 20-Apr-2011 at 12:32pm
Midnit,

Have you had a chance to look into this at all? If you still have a problem, I'd like to help you find the fix.

-- Robert
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 21-Apr-2011 at 7:07am
I am on vacation, next week I should have a chance to go over it again.
Back to Top
robertg View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Mar-2011
Location: California
Posts: 87
Post Options Post Options   Quote robertg Quote  Post ReplyReply Direct Link To This Post Posted: 16-May-2011 at 2:16pm
Midnit,
 
I hope that your vacation was pleasant! Have you had the chance to revisit this issue yet?
 
-- Robert
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 25-May-2011 at 5:06am
I have not revisted this. The code in its current state has passed testing so it appears to be working. I can verify I make no use of the DefaultEntityManager in the interceptor. Well, I use this.EntityManager in the Interceptor - is this correct?
 
 
I changed it to QueryStrategy(FetchStrategy.DataSourceOnly, MergeStrategy.PreserveChanges)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down