【发布时间】:2011-12-24 14:51:08
【问题描述】:
在这个查询中,我有 3 条记录 (int-(telefon = d.telefon), decimal-(pesel = d.pesel), decimal-(nip = d.nip)) 其他记录是字符串。
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();
}
我有错误:
不能隐式转换类型“int?”到'int'。显式转换 存在(您是否缺少演员表?)
还有另外两个“十进制?”错误而不是'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'类型的定义吗?
标签: linq