This is linq-to-sql
I have a lot of different classes all doing the same query, but projecting the results slightly differently. Ideally I\'d like to b
If I understand your question correctly you can use this code:
first declare a method for selecting your data like this:
public List FindAll(Func selector) where TResult : class
{
using (RepositoryDataContext = new DataClasses1DataContext())
{
return RepositoryDataContext.Regions.Select(selector).ToList();
}
}
then you can build your select statement like this:
Func select = r => new SelectAllRegion
{
RegionID = r.RegionID,
RegionDescription = r.RegionDescription
};
my SelectAllRegion
:
public class SelectAllRegion
{
public SelectAllRegion()
{
}
public int RegionID { get; set; }
public string RegionDescription { get; set; }
}
and region is Region
table in northwing.I hope this help you