Print Page | Close Window

Event such as Querying/Fetching/Saving for InvokeServerMethod calls

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3996
Printed Date: 07-Sep-2025 at 7:18am


Topic: Event such as Querying/Fetching/Saving for InvokeServerMethod calls
Posted By: stephenmcd1
Subject: Event such as Querying/Fetching/Saving for InvokeServerMethod calls
Date Posted: 20-Feb-2013 at 4:10pm
The EntityManager class has events such as Querying/Queried, Saving/Saved, Fetching, etc. but none of those fire if you do an InvokeServerMethod (or InvokeServerMethodAsyc) call.  There is some standard logging and other cross-cutting logic that we currently perform in Quering/Queired that we'd really love to be able to do for InvokeServerMethod calls as well.

I made a similar request for the server side of this issue in " http://www.ideablade.com/forum/forum_posts.asp?TID=3597&PID=14284&title=interceptors-for-rpc-methods#14284 - Interceptors for RPC methods? " that didn't get too far.  In that case, it's not too hard (although still annoying) to make sure I add some boilerplate code in every RPC method.  But on the client side, it's much harder to remember to put boilerplate code whenever I invoke a server method.  Plus, making the caller do it makes the code much less readable and harder to maintain.

I'm sure this won't be a super high priority, but I think it would be a somewhat simple change to make and it would really help us out.

Thanks!



Replies:
Posted By: mgood
Date Posted: 20-Feb-2013 at 5:23pm
In the meantime you could create yourself an InvokeServerMethodWithBoilerplateAsync extension method and ensure everybody uses that extension method instead of the raw method on the EntityManager. Gets your boilerplate code out of the way and in one place. Should be very easy to catch during a code review if a developer is bypassing the extension method.


Posted By: kimj
Date Posted: 22-Feb-2013 at 10:06am
Stephen, we haven't completely forgotten your request for RPC interceptors - it's still an open feature request, albeit not very high priority.  We'll add another feature request for a client-side event (or events - do you have a use case for both pre- and post- events?), but please also see if Marcel's suggestion will work for you. 


Posted By: stephenmcd1
Date Posted: 22-Feb-2013 at 12:18pm
Thanks for the update.

Pre- and Post- events would both be helpful.  In some cases, we do timing logic so we need to know when a query started and when it finished.  Post events are also nice because we have access to the results of the operations.  Pre events are nice because we have some hooks to the original operation in case we need to do any tweaking there.

We use InvokeServerMethods in so many places that I ended up giving up on trying to make extension methods and then update all existing usages.  I know it's possible, but it just leaves the chance of human error.  I did find a bit of a workaround by intercepting all WCF calls - this gives me a chance to inspect the calls, dig around and find information about what DevForce is executing.  This gives me the hooks I need to have a pre-event - although, it's not the cleanest solution.

For now, I'll just wait patiently.  It's not the end of the world for us.....but it would still be nice! :-)



Print Page | Close Window