score:0

that seems ok, but you've tagged your question as asp.net. my question to you is how large is this list and how often are you displaying this page?

if you are displaying it often and it isn't too large, i'd pull the slider table into memory and then run your query without hitting the db.

in fact if possible you would cache the entire slider and slideritems if you can.

even if you cache the most recently used if it makes sense to your app, not having to hit the db will give you a better perf increase than optimising what appears to be a very trivial parent / child relationship. i assume you have an index in the database down tbl.id?

score:0

i suggest you can use linq query with join and put the data into the list. it works well for you.

score:1

if your database already has the foreign key relationship between sliders and slideritems in place and if your linq-to-sql model includes both sliders and slideritems, then searching for a slider automatically retrieves all related slideritems:

public static ienumerable<slideritems> getslideritems(guid sliderid)
{
    using (datacontext dc = new datacontext())
    {
        slider result = dc.sliders.single(s => s.id == sliderid);

        return result.slideritems;
    }
}

Related Query

More Query from same tag