Repository
public class ProjectRepository : AudianceRepositoryBase<Project, Guid>, IProjectRepository
{
public ProjectRepository(AudianceDbContext dbContext) : base(dbContext)
{
}
public bool SearchAuditLocation(string sqlQuery)
{
var retValue = false;
var conn = Context.Database.GetDbConnection();
try
{
conn.Open();
using (var command = conn.CreateCommand())
{
command.CommandText = sqlQuery;
var reader = command.ExecuteReader();
if (reader.HasRows)
{
retValue = true;
}
reader.Dispose();
}
}
finally
{
conn.Close();
}
return retValue;
}
}
Raw SQL in EF Core
http://www.learnentityframeworkcore.com/raw-sql
https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/advanced