0

I want to add some conditions(where) to linq in ef codefirst.

using (var context = new Context())
{
            var u= context.Users;
            **u.where(my where condition)**
        }

Is there some way to let me di into all selects , eg:BeforeSelected?

thanks

4

1 に答える 1

1

最も簡単な方法は、DbContextのラッパーを作成することです。

public class EfWrapper:Context
{
 private DbContext _dbContext;

  public EfWrapper(DbContext context){
    _dbContext=context;
  }

  public IEnumerable <User> Users{
     get
     {
        return _dbContext.Users.Where(my where condition);
     }
 }


}
于 2012-04-13T05:38:30.510 に答える