I can not find answers how to implement the following scenario (I do not know what to look for methods). I use C#, .NET FW4.5, Linq to SQL and design pattern repository.
If I want to select all devices, use this code:
/// <summary>
/// Get all Devices
/// </summary>
/// <returns></returns>
public IQueryable<Device> GetDevices()
{
return myDataContext.Devices;
}
If I want to select device by ID, use this code:
/// <summary>
/// Get Device by ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public Device GetDevice(int id)
{
return myDataContext.Devices.SingleOrDefault(
d => d.intDeviceId == id);
}
But how can I implement the following situation?
Select all devices, where are some conditions (and return IQueryable<Device>)
You can use it like :
To use with generics: