Click here to Skip to main content
15,900,816 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi

i need to use this code for find user :

Main Project :

C#
public MainWindow()
  {
      var usersManagerService = StructureMapDefnation.Container.GetInstance<IUser>();

      var qUser = usersManagerService.Find(x => x.Username == "k" && x.Password == "k");
      InitializeComponent();

  }


EFUesrService :

C#
public class EfUserService : EfGenericService<User>, IUser
    {
        public EfUserService(IUnitOfWork uow) : base(uow)
        {
        }
    }


EFGenericService:
C#
public class EfGenericService<T> : IGenericService<T> where T : class
    {
        protected IUnitOfWork Uow;
        protected IDbSet<T> Entites;

        public EfGenericService(IUnitOfWork uow)
        {
            Uow = uow;
            Entites = Uow.Set<T>();
        }
         public T Find(Func<T, bool> predicate)
        {
            return Entites.Where(predicate).FirstOrDefault();
        }
    }


it can not find any this ,but this user "K" is exist in database .

whats the problem ? how can i solve the problem ?

What I have tried:

C#
public T Find(Func<T, bool> predicate)
      {
          return Entites.Where(predicate).FirstOrDefault();
      }
Posted
Updated 29-Jul-17 3:58am
Comments
Graeme_Grant 29-Jul-17 8:12am    
drop the password check and see if the user can be found.
kia9372 29-Jul-17 8:23am    
it can no be found
Graeme_Grant 29-Jul-17 8:32am    
check for case sensitivity

You are searching for lowercase "k" but uppercase "K" is in the database. Change your code reference to the uppercase "K".

As a side note: you should rethink your searching design if case sensitivity is going to prove a show stopper for you.
 
Share this answer
 
v2
Comments
kia9372 29-Jul-17 8:49am    
i change "k" to "kianoush" but it still not show me any things
Graeme_Grant 29-Jul-17 9:03am    
Exactly what I said above.
Slacker007 29-Jul-17 9:13am    
Then make it a solution and not a comment. duh.
Graeme_Grant 29-Jul-17 9:58am    
Done! ;)
check for case sensitivity
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900