This is my code that retrieves information from the database about a list of Printer Drivers. The table has a list of Printer Drivers, as well as what servers they were found on.
public List<PrinterDrivers> GetPrinterDriversFromCache()
{
using (dbPrintSimpleDataContext db = new dbPrintSimpleDataContext())
{
var q = from p in db.GetTable<tblPrinterDriverCache>()
where p.CacheGUID == mostRecentCacheID()
group p by p.PrinterDriver into g
select new PrinterDrivers
{
DriverName = g.Key,
InstalledOn = g.Where(x => x.PrinterDriver == g.Key).Select(x => x.PrinterServer).ToList(),
Usable = (g.Count() == Properties.Settings.Default.PrintServers.Count)
};
return q.ToList();
}
}
What I am trying to return is a List that contains a property that has a List in it that contains what servers that printer driver exists on. I think that I'm up against the limit of my current LINQ SQL knowledge :(
The resultant List should contain:
DriverName = Printer driver name, in this case the group key (string)
InstalledOn = List (containing the list of servers that this printer driver was found on)
Usable = A simple bool check if the servers that it was found on is the same amount as the servers we have in the preferences file.
Thanks for the help :)