ObjectDataSource

D

doug

Hello,

I wish to use declarative datasources as much as possible. Using an
ObjectDataSource makes sense in a few situations.

I see that the TypeName is used to instantiate an object and methods are
called, and parameter can be identified, and feed to the method.

My question is, if i have an object already created as an httphander (ref
would be httpcontext.Users say). Can the reference this object, say
getallusers(), in using an ObjectDataSource?

doug
 
K

Keith Patrick

Problem you'll run into if you need an instance is that the ODS will create
an instance of whatever object you specify itself for every single call, so
if you were to provide it with a handler as your typename, it will create a
separate instance of the type and call *that* object's method rather than
your handler's.
The more efficient way to use ODS is to expose static methods of a class so
that the ODS doesn't attempt to do a default construction of an instance of
the specified object. So in answer to your question, I am pretty sure the
answer it "no" if you need to instantiate the object yourself, unless
there's some trick in there that I've missed (in my own case, I just used
static methods because it fit into my app better)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,230
Latest member
LifeBoostCBD

Latest Threads

Top