implementing effective searching in the business code(with linqmaybe)

G

giddy

hi,

If I have something like:
class Person
{
//functions:
static Person[] GetAllPersons();
static Person[] Search(string field,string value);
}

In the second function I would do something like build an sql query
like this:
SELECT ........... WHERE field = value
and send it through another data class to retrieve the right Persons.

eg:
Person[] teens = Person.Search("Age",18);

Firstly the biggest problem searching with AND, >,<, OR, Between etc.?
Which terribly limits the search.I could make more functions for that,
but its turns into a little bit of a mess. Is there a better/more
generic way to build a query on the fly?

Would I benefit by using Linq instead/would it be more efficient to
load all persons in memory and then search them with linq? If I were
to use linq how again would I write a function to build a query on the
fly?

Thanks so much

Gideon
 
F

Family Tree Mike

I think your send button is stuck. You have posted the same question three
times now. The first time has been answered.


giddy said:
hi,

If I have something like:
class Person
{
//functions:
static Person[] GetAllPersons();
static Person[] Search(string field,string value);
}

In the second function I would do something like build an sql query
like this:
SELECT ........... WHERE field = value
and send it through another data class to retrieve the right Persons.

eg:
Person[] teens = Person.Search("Age",18);

Firstly the biggest problem searching with AND, >,<, OR, Between etc.?
Which terribly limits the search.I could make more functions for that,
but its turns into a little bit of a mess. Is there a better/more
generic way to build a query on the fly?

Would I benefit by using Linq instead/would it be more efficient to
load all persons in memory and then search them with linq? If I were
to use linq how again would I write a function to build a query on the
fly?

Thanks so much

Gideon
 
G

giddy

Jeez, this happens every now and then, but this time, i posted and it
didn't show up in the forum for a couple hours I think, then i posted
again.

What do you guys use to post here, I use google groups.

Thanks so much

Gideon
 

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

Top