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;
}
}
Source: stackoverflow.com
Related Query
- C# Joining 3 Lists with Linq
- How to merge two lists while adding metadata indicating value source with LINQ statement?
- LINQ - Joining 3 tables and selecting an item with two lists
- joining two lists in linq with a field as an array in one list and simple string in other list in C# Linq
- Create a list from two object lists with linq
- LINQ Joining in C# with multiple conditions
- Flatten a C# Dictionary of Lists with Linq
- Search two lists for at least one match with LINQ
- Merge multiple Lists into one List with LINQ
- Left join on two Lists and maintain one property from the right with Linq
- Concatenating three lists into one with LINQ throws an exception
- Combine two potentially null lists with linq
- Concatenating two lists of different types with LINQ
- Using Linq Except with two lists of int arrays
- Joining two tables with LINQ while also returning null records from the second table
- C# - Linq with two Lists
- LINQ Source Code Available
- Using Linq to compare a list with a set of lists in C#
- Linq with where clause in many-to-many EF Code First object
- How to create a list from filtering 2 lists with linq to object
- LINQ for comparing two lists with complex entities
- Using Linq and C#, is it possible to join two lists but with interleaving at each item?
- I'm trying to simplify with linq a statement that takes 2 lists of numbers and subtracts the first one from the second one
- Joining 2 Lists with LINQ?
- C# Combine two lists with nested lists into one using LINQ
- Split list into two lists with single LINQ statement
- Joining strings in a JArray with LINQ
- Compare two object lists with LINQ on specific property
- C# - Linq optimize code with List and Where clause
- creating Linq to sqlite dbml from DbLinq source code
More Query from same tag
- Set value if sublist contain specific object with Linq
- C# extracting ID from list of structures using LINQ
- How can I convert this linq expression to method form?
- Error getting when trying assign linq data into DTO class
- LINQ SingleOrDefault, Brush, what I am doing wrong?
- Format List<T> to concatenate fields
- XML to LINQ parsing of an XML with namespace in C#
- Dynamic LINQ Expression for sorting navigation property
- Create a linq subquery returns error "Local sequence cannot be used in LINQ to SQL implementations of query operators except the Contains operator"
- How to merge two lists using LINQ Suming a especific field when the id matched
- how apply string.contains method in generic lambda expression
- Linq extension. Change property value in source list
- IEnumerable.Count() or ToList().Count
- How do I Filter LINQ query by date?
- LINQ error : The query results cannot be enumerated more than once
- LINQ query to get all products with in Min & Max price range?
- Iterate through Linq to Entities results until condition is met
- Getting 2 Top 5 within a single LINQ query in EFCore
- C# Linq full outer join on repetitive values
- Linq group by + where for each group
- C# Dynamic Linq Ternary Operator
- Comparing two classes in LINQ - getting 'mismatches'
- Flatten LINQ collection object with nested object collections
- Linq to Sql Datacontext primary key not set
- LINQ generating SQL not supported by SQL Server 2008R2
- How to use the same query which has the random value after I click next button
- LINQ Select Many question
- How to get the last not logged-in user's within three weeks backwards?
- C# multidimensional array into array
- pass ID from grid view in linq