Hello,
I want to get a record using 2 tables. The 2 models are as below.
public class RAJ_DAILY_SHABD
{
[Key]
public int Sr_No { get; set; }
public string Display_Dt { get; set; }
}
public class RAJ_AAJ_KA_SHABDH
{
[Key]
public int Sr_No { get; set; }
public string English_Description { get; set; }
public string Hindi_Description { get; set; }
public string Last_Trans_Date { get; set; }
public string Flags { get; set; }
}
I need to get English and Hindi description from the table Raj_Aaj_Ka_Shabd where sr_no is equal to sr_no in raj_daily_shabd table.
My ViewModel code is as below.
public class HomePageVM
{
public List<RAJ_AAJ_KA_SHABDH> AajKaShabd { get; set; }
public List<RAJ_DAILY_SHABD> DailyShabd { get; set; }
public string DailyHindi { get; set; }
public string DailyEnglish { get; set; }
}
My controller code is as below.
public async Task<IActionResult> Index()
{
HomePageVM VM = new HomePageVM()
{
AajKaShabdTitle = GetHindiText(_db.Frontend_Text.Where(p => p.lbl_name == "AAJ_KA_SHABD").FirstOrDefault().lbl_text.ToString()),
//This is where i want the 2 colums from table raj_aaj_ka_shabd.
//DailyHindi = _db.RAJ_AAJ_KA_SHABDH.Where(p => p.Sr_No in _db.RAJ_DAILY_SHABD.FirstOrDefault(s => s.Sr_No))
};
return View(VM);
}
Please guide.
Regards