![]() |
| Ew. |
But don't despair, there is a fairly easy fix. We can use the
tab-size CSS property to define the tab size on the page.
Thoughts and tutorials on software development and the web.
![]() |
| Ew. |
tab-size CSS property to define the tab size on the page.
onContextMenu which calls e.preventDefault() to stop the event from bubbling up.
element.onContextMenu.listen((MouseEvent e) => e.preventDefault());
.Any() in your LINQ to SQL queries
.Any() over .Count() as the SQL will be optimised to only get the information required. .Any() will use EXISTS in SQL which stops as soon as a record is found whereas .Count() uses COUNT(*) which goes through all the records to get the number matching the query. var q1 = TableName.Count() > 0; var q2 = TableName.Any();They will produce the following SQL:
-- q1
SELECT COUNT(*) AS [value]
FROM [TableName] AS [t0]
-- q1
SELECT
(CASE
WHEN EXISTS(
SELECT NULL AS [EMPTY]
FROM [TableName] AS [t0]
) THEN 1
ELSE 0
END) AS [value]
As you can see the second sample produces some admittedly uglier SQL but is much more efficient.
Dictionary objects and want their contents merged, this can be done with LINQ very conveniently like so.
var mergedDictionary = dictionaries
.SelectMany(e => e)
.ToLookup(e => e.Key, e => e.Value)
.ToDictionary(e => e.Key, e => e.First());
There is a major issue with this method though in that it's quite horrible performance-wise, the reason being because of the amount of conversions and unnecessary work that is happening. Firstly SelectMany is flattening the IEnumerables into a single IEnumerable, then we're converting the new IEnumerable into a Lookup and then we're converting the Lookup into a Dictionary taking only the first value for any key in the Lookup to resolve duplicates.