Entity Framework (EF) Core / LINQ

18. 12. 13
posted by: Admin
Hits: 59

Entity Framework (EF) Core / LINQ

Contoh 1 :
var isExistDataYangDicari = await this.DbContext.NamaTabel.FirstOrDefaultAsync(Q => Q.NamaKolom == model.NamaKolom);
if (isExistDataYangDicari != null)
{
return ("ketemu", null);
}

Contoh 2 :
var existingData = await this.DbContext.NamaTabel.Where(Q => Q.NamaKolom_1 == Value_1
&& Q.NamaKolom_2 == Value_2
&& Q.NamaKolomTanggal >= DateTimeOffset.Now)
.ToListAsync();
if (existingData == null)
{
return false;
}