this is my controller code:
var myquery = mycontext.Websites.Select(x => new {x.pagetype,x.website1,x.creationdate,x.expirationdate,x.domainregistrar,x.area,x.pin
,x.city, age = DateTime.Now.Subtract(x.expirationdate ?? DateTime.Today)
});
return View(myquery);
and this is my view code:
@foreach (var item in Model)
{
<tr>
<td>
<span>@item.pagetype </span>
</td>
</tr>
}
how ever its giving me error: object does not contain definition of pagetype while traversing through foreach loop?
i wonder why?
EDIT:
I tried changing the code as below:
Controller:
CRMDataContext mycontext = new CRMDataContext();
var myquery = mycontext.Websites.Select(x => new WebsiteViewModel
{
pagetype = x.pagetype,
site = x.site,
creationdate = x.creationdate ?? DateTime.Today,
expirationdate = x.expirationdate ?? DateTime.Today,
domain_registrar = x.domainregistrar,
Area = x.area,
pin = x.pin,
City = x.city,
difference = DateTime.Now.Subtract(x.expirationdate ?? DateTime.Today).ToString()
}).ToList();
return View(myquery);
but i'm getting exception:
Operation could destablize operation at runtime. Make sure your application is not loading two conflicting version of class library
all i can think..is linq generated class for Website table and my Websiteview model is conflicting . but i can not understand why?