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.
Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)
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.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi @Chrisk ,
Thanks for the answer :)
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)