net mvc core 2.2 and Mssql.I wrote a stored procedure which is working fine. The result:
However whenever I run my app all of stockPermit column returns false.
if (!String.IsNullOrEmpty(searchString))
{
searchString = Methods.RemoveTurkish(searchString);
bayiVM.JoinedTable = await _adb.CariUserJoin.FromSql("EXECUTE CariListeAra {0}", searchString).ToListAsync();
}
else
{
bayiVM.JoinedTable = await _adb.CariUserJoin.FromSql("EXECUTE CariListeGetir").ToListAsync();
}
var count = bayiVM.JoinedTable.Count;
bayiVM.JoinedTable = bayiVM.JoinedTable.Skip((productPage - 1) * PageSize).Take(PageSize).ToList();
bayiVM.PagingInfo = new PagingInfo
{
CurrentPage = productPage,
ItemsPerPage = PageSize,
TotalItems = count,
urlParam = param.ToString()
};
return View(bayiVM);
Result in Debug:
What can cause this problem. I appreciate any help.Thank you.
ALTER PROCEDURE [dbo].[CariListeGetir]
AS
BEGIN
SELECT [CARI_KOD], [CARI_ISIM], [LockoutEnd],[PlaKodu], [StockPermit] FROM YESLAS2018.dbo.TBLCASABIT
left join b2byeslasDb.dbo.AspNetUsers on TBLCASABIT.CARI_KOD=AspNetUsers.UserName
END
ALTER PROCEDURE [dbo].[CariListeAra] (@ad nvarchar(15))
AS
BEGIN
SELECT [CARI_KOD], [CARI_ISIM], [LockoutEnd],[PlaKodu], [StockPermit] FROM YESLAS2018.dbo.TBLCASABIT
left join b2byeslasDb.dbo.AspNetUsers on TBLCASABIT.CARI_KOD=AspNetUsers.UserName
where CARI_KOD like '%'+@ad+'%' or CARI_ISIM like '%'+@ad+'%'
END
public class BayiVewModel
{
public List<CariUserJoin> JoinedTable { get; set; }
public PagingInfo PagingInfo { get; set; }
}
public class CariUserJoin
{
[Key]
public string CARI_KOD { get; set; }
public string CARI_ISIM { get; set; }
public DateTimeOffset? LockoutEnd { get; set; }
public string PlaKodu { get; set; }
public bool StockPermit { get;set}
}
PS:I used LEFT JOIN. I mean left table has 4500 rows and right table has 30.
Please use:
public bool? StockPermit { get; set; }
set;
is needed so that the property can actually be set. ?
is needed to make it nullable.