Hi all,
Should I be doing my automapping in my service layer or at my controller?
I like the Idea of
Repository - Raw data IQueryable type stuff with full domain(type) objects.
Service layer - Paged, Ordered, Filtered, Automapped View model to return
Controller - Push the view with the correct model
But having seen some nice stuff wi...
I saw this code work with LINQ to SQL but when I use Entity Framework, it throws this error:
LINQ to Entities does not recognize the method 'System.Linq.IQueryable'1[MyProject.Models.CommunityFeatures] GetCommunityFeatures()' method, and this method cannot be translated into a store expression.
The repository code is this:
public ...
So, I'm developing some software, and trying to keep myself using TDD and other best practices.
I'm trying to write tests to define the classes and repository.
Let's say I have the classes, Customer, Order, OrderLine.
Now, do I create the Order class as something like
abstract class Entity {
int ID { get; set; }
}
class Order : ...
How do you use LINQtoSQL with the repository pattern?
I’m new to L2S and find its lazy loading to be a real impediment to using the repo pattern.
Usually, I think of the repository pattern like this:
var myCustomer = null;
using (var myRepo = new Repo()){
myCustomer = myRepo.GetCustomerForCustomerId(123);
}
if(myCustomer.Or...
Hi,
I have an ASP.NET MVC 2 project. I've decoupled layers. I have a service layer and a repository layer.
The controller calls service methods and only the service layer calls methods in the repository.
The problem is:
A method in my repository class uses LINQ joins. From this method, I would like to return a type with merging some da...
Hello all,
Been around here for a while but this is my first question @ so.
Scenario:
Mvc site. Viewmodels for most pages.
Each viewmodel contains models or iqueryables acquired from different repositories.
Each source is updated frequently (from outside the scoop of the site) so even if caching local it will be a lot of datasource h...
Im trying to implement an unit of work pattern by passing an unit of work instance into my repositories.
Relevant code from Global.asax.
public class SiteModule : NinjectModule
{
public override void Load() {
Bind<IUnitOfWork>().To<SqlUnitOfWork>()
.InRequestScope()
...
I have the following repository that I use for unit testing:
public class MyTestRepository<T>
{
private List<T> entities = new List<T>();
public IQueryable<T> Entities
{
get { return entities.AsQueryable(); }
}
public T New()
{
//return what here???
}
public void Create(T entity)
{
...
Hi,
We have an ASP.NET MVC site that uses Entity Framework abstractions with Repository and UnitOfWork patterns. What I'm wondering is how others have implemented navigation of complex object graphs with these patterns. Let me give an example from one of our controllers:
var model = new EligibilityViewModel
{
Country = pers...
I am new to repositories. I just read about implementing predicates and a Unit of Work (Fowler). I have seen repository interfaces like the following:
public interface IRepository<ET> {
ET Add( ET entity);
ET Remove( int id);
ET Get( int id);
IList<ET> Get(Expression<Func<T, bool>> predicate);
}
...
I have CompanyController and DepartmentController:
public class CompanyController : BaseBackendController
{
private ICompanyRepository repository;
public CompanyController(ICompanyRepository repository)
{
this.repository = repository;
}
...
[HttpPost]
public ActionResult BatchDelete(long[] ids)
{
var e...
I want to do paging outside of my Repository, but the Repository returns IList. Since I don't want to pull data unnecessarily, and don't want to create specific Paging methods in my Repositories, Is there any way to filter records by page in the Where extension method?
I want to do something like:
var myRecords = ProductRepo.Get( p =>...
I am creating a store with ASP.NET 4.0 MVC and C# and am fairly new to it.
I have come to creating the View page that displays the products within a certain category.
On the specific category page I want to have the product list and also want the category name with its relevant description taken from the database.
Currently the way I ...
I use Entity Framework 4.
How can I perform a Generic Where Lambda Clause.?
I Have many Entity that need the same Where Query.
public Func<SupplierTypeText, bool> GetLmbLang()
{
return (p => p.LangID == 1);
}
public Func<ProductText, bool> GetLmbLang()
{
return (p => p.LangID == 1);
}
public Func<CategoryText, bool> GetLmbL...
If you populate a drop down list of possible values, you only want the database query to pull two fields, a value and text (like customer ID and Name).
However, your Repository returns POCOs, namely the entire Customer record.
I wouldn't think you should create a POCO for every single DDL list you need, so how does one specify to a rep...
I Have 3 entities.
Product
LangID
ProductName
Category
LangID
CatName
ProductType
LangID
TypeName
As you can see, each of them has LangID Property.
I Would like be able to create a generic repository that will contain only one function that will return an Func<T, bool> GetLmbLang()
public interface IBaseRepository<T> where T : c...
If you return IList(T) from your repository ...
How could you efficiently create SQL queries when you join the data together?
Is it REQUIRED to expose IQueryable / IEnumerable data structures for those methods? This to me is bad.
Or
Am I missing some basic concept?
Right now I have a repository methods like:
IList<T> Get( Expressi...
What would the C# code be to create a (service) method to return an object (ViewModel for DDL) using AutoMapper and provide the two field names as parameters?
DDL is for a Drop Down List:
public class DDLitems {
public string text {get;set;}
public string value {get;set}
}
My horrible pseudo C# code idea: (yea no idea how to ...
I have a SVN project at work that looks like this:
Repository
project
|-- docs
|-- scripts
`-- app
|-- trunk
|-- branches
| `-- development
`-- tags
|-- Release_1.0
|-- ...
`-- Release_5.3
I want my working folder like this:
Working copy
dir_root
...