2

I am using Asp.Net boilerplate framework, I created a table in database by Code-First approach. Now i want to get Records from that table but applying query like this returning empty data. Why?

 MyAppDbContext db = new MyAppDbContext();
 var list = db.NewTables.ToList();

But List is returned as empty while table contains data actually.

0

1 Answer 1

3

Inject IRepository instead of using DbContext directly:

public class TaskManager : DomainService, ITaskManager
{
    private readonly IRepository<Task, long> _taskRepository;

    public TaskManager(IRepository<Task, long> taskRepository)
    {
        _taskRepository = taskRepository;
    }

    public void GetTasks()
    {
        var tasks = _taskRepository.GetAll().ToList();
    }
}

Read more in ABP documentation:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.