0
okeziestanley created
Hi guys, the IRepository always throws an exception if you try to get an entity with id when such id doesn't exist. But what I want is for it to return null. How can I do this. I am using Entity framework.
2 Answer(s)
-
0
Hi,
I believe that IRepository.Get() method is meant to return exception if record was not found. You can use .FirstOrDefault() to do that. For example UserManager class has GetById and FindById methods where later works as you want.
-
0
Hi @Chrisk ,
Thanks for the answer :)