I am working on an asp.net mvc-5 web applicatio. i have these two model classes:-
public class ScanInfo
{
public TMSServer TMSServer { set; get; }
public Resource Resource { set; get; }
public List<ScanInfoVM> VMList { set; get; }
}
public class ScanInfoVM
{
public TMSVirtualMachine TMSVM { set; get; }
public Resource Resource { set; get; }
}
and i have the following method:-
List<ScanInfo> scaninfo = new List<ScanInfo>();
List<String> CurrentresourcesNames = new List<String>();
for (int i = 0; i < results3.Count; i++)//loop through the returned vm names
{
var vmname = results3[i].BaseObject == null ? results3[i].Guest.HostName : results3[i].BaseObject.Guest.HostName;//get the name
if (!String.IsNullOrEmpty(vmname))
{
if (scaninfo.Any(a => a.VMList.Any(a2 => a2.Resource.RESOURCENAME.ToLower() == vmname.ToLower())))
{
CurrentresourcesNames.Add(vmname);
}
}
}
var allcurrentresourcename = scaninfo.Select(a => a.VMList.Select(a2 => a2.Resource.RESOURCENAME)).ToList();
var finallist = allcurrentresourcename.Except(CurrentresourcesNames).ToList();
now i want to get all the String that are inside the allcurrentrecoursename
list but not inside the CurrentresourcesName
?
but that above code is raising the following exceptions :-
Error 4 'System.Collections.Generic.List>' does not contain a definition for 'Except' and the best extension method overload 'System.Linq.Queryable.Except(System.Linq.IQueryable, System.Collections.Generic.IEnumerable)' has some invalid arguments
Error 3 Instance argument: cannot convert from 'System.Collections.Generic.List>' to 'System.Linq.IQueryable'