私は3つのレコードを持っています(int-(telefon = d.telefon)、decimal-(pesel = d.pesel)、decimal-(nip = d.nip)他のレコードは文字列です。暗黙的に型 'int?'を変換できません。 to 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?)
と2別のエラーを代わりに '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が、残りnonnullableあるがnull
を許可している///////////////////// ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// //////////
現在作業中です。私はモデルに変更します
decimal to decimal?
と
int to int?
はあなたが決定的な答えを得るために、より多くのコードをポストする必要がありますが、どこかの変数のいずれかよ、あなたに助け
なぜuzytkownikModelクラスを表示しないのですか?フィールドやプロパティの値が同じ型と一致しないため、おそらくあなたはそのエラーを受け取ります。 –
あなたは 'd'のタイプの定義を投稿できますか? – JohnD
もっとコードを追加しました – user1031034