Hi all.  I'm a little stumped on the best way to accomplish this query.  I 
have an object, Jobs, which maps to a database table with the following 
columns:

ID
Name
Description
DatabaseServer

DatabaseServer is also an object which maps to the DatabaseServers table 
with the following columns:

ID [Column = "DatabaseServerID")]
Description
IsActive (bool)

Normally, if I wanted to query the Jobs table, I would use something like 
the following: ActiveRecordBase<Jobs>.FindAll().ToList();

The problem I have is I want to use this same method to query based off 
whether the a job has a DatabaseServer that IsActive.

I've tried the following:
ActiveRecordBase<Jobs>.FindAll().Where(x => 
x.DatabaseServer.IsActive).ToList();

But, this takes forever to run.  I have approximately 5000 records in the 
jobs, table.

Using straight sql, this is really quick and easy: select * from jobs where 
databaseserverid in ( select databaseserverid from databaseservers where 
isactive = 1 )

But, I'm trying to return a List<Job> object, and don't want to get a 
DataSet and manually map it to my Job object for each row in the Dataset.

Any ideas on how to efficiently accomplish this?  Sorry if I've overlooked 
something completely obvious.  I'm getting tunnel vision at this point.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to castle-project-users+unsubscr...@googlegroups.com.
To post to this group, send email to castle-project-users@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to