selecting data in database with different queries

J

Jeff

hi

asp.net 2.0
sql server 2005

I have a GridView on my webpage. Sometimes I want to query the bound
datasource in different ways.:
- Get all arroved records
- Get all unapproved records
- Get all records created last week
- Get all records created by current user.
- Get top 100 records (return 100 records)

this is a standard table in a database on sqlserver 2005. primary key is
uniqueidentifier

Hope there are a better way of doing this than creating multiple stored
procedures....

any suggestions?
 
J

Jeff

Thanks for that link.

But now I'm wondering if there is another possible approach. The thing is
that my DAL creates a collection of the objects.
for example List<car> cars = siteprovider.getCars();

So maybe a possible workaround to using xml parameter is to in the
application start event put some logic that reads in the entire collection
of cars and then store it the cache. And then use the search mecanism on the
list (List<car>) to get the cars I want. In that approach I don't need to
make another trip to the database.

One issue I see is that perhaps sometime the cache will be lost, but then
maybe make a new trip to the database and return all the records. Then store
it in cache etc...

any suggestons? problem using this approach?
 
S

sloan

Sure.

"workaround to xml parameter"
Why would you fear using xml? Sql Server does a nice job of shredding them.

But you can put the data into cached object.

However, it dependings on how many optional filters you need to code.
If you have alot, it won't be trivial.

I would research the "Filter" using Ludwig's very good article:
http://www.scribd.com/doc/2057557/CTG-Articles-Generics

I foresee a maze of Filter methods......but maybe you can figure out
something.
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top