Wednesday, May 13, 2015

How to update rows with a random date

UPDATE table SET datetimecol = DATEADD(day, (ABS(CHECKSUM(NEWID())) % 65530), 0)

How to convert IList to IQuerable

IQueryable query = new List() { 1, 2, 3, 4, 5}.AsQueryable();

How to check if IQueryable result set is null or empty

list will never be null with LINQ; it will simply represent an "empty collection" if need be. The way to test is with the Any extension method:
if (list.Any()) 
{
// list has at least one item
}

What “exec sp_reset_connection” shown in Sql Profiler means?

sp_reset_connection indicates that connection pool is being reused

Saturday, May 9, 2015

Disabling Chrome, Firefox, Safari, Opera, IE Autofill

<form>
<!-- fake fields are a workaround for chrome autofill getting the wrong fields -->
<input style="displaynone" type="text" name="fakeusernameremembered" />
<input style="displaynone" type="password" name="fakepasswordremembered" />
</form>