Reputation: 13006
In my controllers, I initialize my unit of work and repository patterns as follows:
private readonly IUnitOfWork _unitOfWork;
private readonly IRepository<Website> _repository;
public ProjectsController() { }
public ProjectsController(IUnitOfWork unitOfWorkAsync,
IRepository<Website> repository)
{
_unitOfWork = unitOfWorkAsync;
_repository = repository;
}
And my basic usage is as follows:
var website = _repository
.Query()
.Select()
.Single(u => u.UserId == userId && u.WebsiteGuid == websiteGuid);
I would like to use Linqpad to test out the queries, and would like to know if and how to use Linqpad to do this.
I first make a connection to the db context, then connect to the Repository.dll to avoid the following errors:
The type 'Repository.Pattern.DataContext.IDataContextAsync' is defined in an assembly that is not referenced. You must add a reference to assembly 'Repository.Pattern, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. (Press F4)
The type 'Repository.Pattern.DataContext.IDataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'Repository.Pattern, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
So now that everything is connected, I'm at a loss on how to proceed.
Upvotes: 2
Views: 961
Reputation: 13006
Thanks to Sorax's tip, instead of using C# statement(s), I changed the language to C# program.
I added a reference to Repository.Pattern.Ef6\bin\Repository.Pattern.Ef6.dll and wrote a basic working query as follows:
void Main()
{
//IRepository<Website> _repository = ;
var _repository = new Repository.Pattern.Ef6.Repository<Website>(this);
var website = _repository
.Query()
.Select();
website.Dump("The Oputput...");
}
Upvotes: 3
Reputation: 2203
I'm making some assumptions here, such as your repository has a dependency on the DBContext connection you created. So it should just be a matter of initializing an instance:
var userId = new Guid("...");
var websiteGuid = new Guid("...");
var _repository = new Repository<Website>(this);
var website = _repository
.Query()
.Select()
.Single(u => u.UserId == userId && u.WebsiteGuid == websiteGuid);
website
.Dump();
Upvotes: 2