LINQ: When to use SingleOrDefault vs. FirstOrDefault() with filtering criteria
If your result set returns 0 records: SingleOrDefault returns the default value for the type (e.g. default for int is 0) FirstOrDefault returns the default value for the type If you result set returns 1 record: SingleOrDefault returns that record FirstOrDefault returns that record If your result set returns many records: SingleOrDefault throws an exception … Read more