I have a piece of code
string phoneMobileW = null;
string phoneMobileP = null;
string phoneMain = null;
string phoneWork = null;
string phoneHome = null;
if (coreData.ListOfAddress_0006 != null && coreData.ListOfAddress_0006.Count() > 0)
{
var phoneqry = from list in coreData.ListOfAddress_0006
.Where(a => a.Subtype.ID == "1")
.OrderByDescending(a => a.StartDate)
.Take(1)
.Where(p => p.ListOfPhoneNumber_0006 != null)
.SelectMany(p => p.ListOfPhoneNumber_0006)
select list;
if (phoneqry != null)
{
var phoneList = phoneqry.ToList();
phoneMobileW = phoneList
.Where(q => q.NumberType.ID == "MOBW")
.Select(q => q.Number)
.LastOrDefault();
}
}
The phone numbers are contained inside the address. If the address is not empty get the last phone number. However I have coped and pasted this piece of code over to another class it and it longer works.
So where it works you can see the 'var' for phoneqry is interface System.Collections.Generic.Ienumerable
As I said I have copied it over to another class which is a unit testing class. I am trying to populate the phone number.
When I hold the cursor over var, nothing appears to show me what object it is(is this because its in a unitTest class?)
anyway the error I get is for .Where in var phoneqry = from list in coreData.ListOfAddress_0006.Where
Error 4 'System.Array' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?) D:\MartinsCode\New folder\Trunk\BusinessLogic\SapEai.UnitTest\AdUnitTest.cs 166 73 RFS.BusinessLogic.SapEai.UnitTest