ASP.NET MVC 3 Application using Ninject, Entity Framework 4 Code-First CTP 5, Patterns

后端 未结 2 1218
温柔的废话
温柔的废话 2021-01-30 07:35

I\'ve tried to build some base project with above technologies. I wanted maximum flexibility and testability so I tried to use patterns along the way to make this as a base for

2条回答
  •  独厮守ぢ
    2021-01-30 08:08

    One small observation: by having your EFRepositoryBase and IReviewRepository have methods that return an IEnumerable<> instead of an IQueryable<>, you prevent subsequent methods from adding filter expressions/constraints or projections or so on to the query. Instead, by using IEnumerable<>, you will do any subsequent filtering (e.g. using LINQ extension methods) on the full result set, rather than allowing those operations to affect and simplify the SQL statement that gets run against the datastore.

    In other words, you are doing further filtering at the webserver level, not at the database level where it really belongs if possible.

    Then again, this may be intentional - sometimes using IEnumerable<> is valid if you do want to prevent callers of your function from modifying the SQL that is generated, etc.

提交回复
热议问题