If you have two tables A and B, both with column C, here are the records, which are present in the table A but not in B: SELECT A.* FROM A LEFT JOIN B ON (A.C = B.C) WHERE B.C IS NULL To get all the differences with a single query, a full join must be used, like this: […]
Tag: difference
What is the difference between HashSet and List in .net?
Unlike a List<> A HashSet is a List with no duplicate members. Because a HashSet is constrained to contain only unique entries, the internal structure is optimized for searching (compared with a list) – it is considerably faster Adding to a HashSet returns a boolean – false if addition fails due to already existing in […]
Differences between FirstOrDefault and SingleOrDefault in LINQ
Whenever you use SingleOrDefault, you clearly state that the query should result in at most a single result. On the other hand, when FirstOrDefault is used, the query can return any amount of results but you state that you only want the first one. If your result set returns 0 records: Single throws an exception First throws an exception SingleOrDefault returns the default […]
How to calculate difference (number of days) between two dates in C#
Let’s say we haveStartDate and EndDate and those are of type DateTime. If you want to have an int value as a result then: int theResult = (EndDate – StartDate).Days; And if you want to have a double value as a result then: double theResult = (EndDate – StartDate).TotalDays;