Reputation: 3129
I am running into this error
cannot convert from 'System.Collections.Generic.List' to 'HWC.DataAccess.FAREmailList' HWC.DataAccess
I am not understanding this error because its the same list type
here is the method that I am using
public void PrepareToSendEmailFromFAR(int id)
{
HWC = new HWCEntities();
FileAReport far = HWC.FileAReports.Where(w => w.FileAReportID == id).FirstOrDefault();
List<FAREmailList> emailList = null;
if(far.DistrictID != 0)
{
emailList = new List<FAREmailList>();
var query = from dcx in HWC.DistrictContactXREFs
where
dcx.DistrictID == far.DistrictID
select new
{
dcx.ContactID,
dcx.Contact.ContactEmail,
dcx.Contact.ContactName
};
foreach(var a in query)
{
emailList.Add(new FAREmailList
{
ContactName = a.ContactName,
EmailAddress = a.ContactEmail
});
}
SendEmailFromFAR(emailList);
}
if(far.DistrictID == 0)
{
emailList = new List<FAREmailList>();
var query = from dcx in HWC.DistrictContactXREFs
join d in HWC.Districts on dcx.DistrictID equals d.DistrictID into d_join
from d in d_join.DefaultIfEmpty()
join sp in HWC.StateProvinces on new { StateProvinceID = d.StateID } equals new { StateProvinceID = sp.StateProvinceID }
where
d.StateID == far.StateCountyID
select new
{
dcx.ContactID,
dcx.Contact.ContactEmail,
dcx.Contact.ContactName
};
foreach (var a in query)
{
emailList.Add(new FAREmailList
{
ContactName = a.ContactName,
EmailAddress = a.ContactEmail
});
}
SendEmailFromFAR(emailList);
}
}
and here is the method thats receiving the emailList
public void SendEmailFromFAR(FAREmailList el)
{
}
the data class is
public class FAREmailList
{
public string ContactName { get; set; }
public string EmailAddress { get; set; }
}
the error is being thrown at
SendEmailFromFAR(emailList);
I am not seeing what the issue is, is it because this is all in the same class file?
Upvotes: 0
Views: 51
Reputation: 10917
The error makes sense to me. emailList
is of type List<FAREmailList>
and SendEmailFromFAR
takes a FAREmailList
as input.
Upvotes: 3