在这个查询中我有3条记录(int-(telefon = d.telefon),decimal-(pesel = d.pesel),decimal-(nip = d.nip))另一条记录是字符串。不能隐式转换类型'int?' 'int'
public ActionResult detail(int LoginID)
{
var user = (from d in baza.uzytkowniks
where LoginID == d.LoginID
select new uzytkownikModel {
imie = d.imie,
nazwisko = d.nazwisko,
telefon = d.telefon,
pesel = d.pesel,
nip = d.nip,
email = d.email,
adres_zamieszkania = d.adres_zamieszkania}).ToList();
ViewBag.daneuser = user;
return View();
}
而且我有错误:
Cannot implicitly convert type 'int?' to 'int'. An explicit conversion exists (are you missing a cast?)
和两个其他错误'小数?而不是'int?'。
型号:
public class uzytkownikModel
{
[Required]
public string imie { get; set; }
[Required]
public string nazwisko { get; set; }
public decimal pesel { get; set; }
public decimal nip { get; set; }
public string adres_zamieszkania { get; set; }
public int telefon { get; set; }
public string email { get; set; }
}
只有IMIE和nazwisko是不可为空的,其余都允许空
///////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////// //////////
现在工作。我在模型发生变化:
decimal to decimal?
和
int to int?
谢谢大家的帮助,你的变量的
为什么你不显示uzytkownikModel类?可能你得到的错误,因为字段或属性不符合与您的值相同的类型。 –
你可以发布'd'类型的定义吗? – JohnD
我增加了更多代码 – user1031034