I have tried to retrieve data from SQL database. I am using Entity Framework core. Its retrieving the required data from the database. I can see the data coming when debugging but the data is not assigning to the variable of type var. FYI, the value of variable type is 0 and its basically an enum, i typecast it to int. Below is the code
public async Task<string> GetMailTemplateByType(Models.TemplateTypes type)
{
var mailTemplate = await _userDbContext.MailTemplates.FirstOrDefaultAsync(mt => mt.TemplateType==((int)type));
return mailTemplate.MailHtml;
}
Here is the definition:
var HtmlTemplate = await _coreDataManager.GetMailTemplateByType(TemplateTypes.Activation);
when debug with try catch, Its showing
Object reference not set to an instance of an object
what is the problem here?