I'm asking this because I would like to store those command objects in appfabric cache and execute them at a later stage through a batch once a day. (to reduce the number of uneven database hits). These are pure update statements and don't return anything.
Asked
Active
Viewed 639 times
1 Answers
2
The short answer is yes. However I wouldn't recommend doing it. Instead I would just pass the query itself as a string and create the SQLCommand in the service.
This question explains how to pass an object from a client app to a WCF service; How to pass Client Objects to WCF Service
Basically if you create the SQLCommand object client side you're; 1) allocating/initializing an object 2) having that object serialized and deserialized into an equivalent object in the service.
If you pass it a string you're instead; 1) allocating/initializing a string 2) passing it to the service which allocates and initializes a SQLCommand object.
The latter is simpler and more efficient.

Community
- 1
- 1

evanmcdonnal
- 46,131
- 16
- 104
- 115
-
1Generally, don't store in cache executing objects. Store ready to use data. – T.S. May 02 '13 at 17:32
-
Im actually serving a group of projects which need a common API for appfabric cache and all of them do the common job of inserting data.so if it was a command object passed to a service (with minimum lines of code written at the consuming project's end) it would be nice. And how would I handle the arguments if I'm passing parameters to the command object? That would make it passing the string containing the stored procedure and an array containing the input parameters. Any ideas on how I can handle it? Thanks in advance! – krishwader May 03 '13 at 00:38