-
-
Save JohannesSundqvist/22b6bb4446891d22aeb40aaa9f50c580 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DataContext : DbContext, IDataContext | |
{ | |
public DbSet<Customer> Customers { get; set; } | |
public Customer FetchTableData() | |
{ | |
var query = (from a in Customers | |
where a != null | |
select a).FirstOrDefault(); | |
return query; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IDataContext | |
{ | |
Customer FetchTableData(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private IDataContext _context; | |
public MainController(IDataContext context) | |
{ | |
_context = context; | |
} | |
public IActionResult MainPage() | |
{ | |
var getData = _context.FetchTableData().Name; | |
ViewData["DisplayName"] = getData; | |
return View(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment