Skip to main content

Posts

Showing posts from October, 2017

POWERS OF TWO up to 2^221

POWERS OF TWO up to 2^221 2^–2 1/4 2^–1 1/2 2^0 1 2^1 2 2^2 4 2^3 8 2^4 16 2^5 32 2^6 64 2^7 128 2^8 256 2^9 512 2^10 1024 2^11 2048 2^12 4096 2^13 8192 2^14 16384 2^15 32768 2^16 65536 2^17 131072 2^18 262144 2^19 524288 2^20 1048576 2^21 2097152 2^22 4194304 2^23 8388608 2^24 16777216 2^25 33554432 2^26 67108864 2^27 134217728 2^28 268435456 2^29 536870912 2^30 1073741824 2^31 2147483648 2^32 4294967296 2^33 8589934592 2^34 17179869184 2^35 34359738368 2^36 68719476736 2^37 137438953472 2^38 274877906944 2^39 549755813888 2^40 1099511627776 2^41 2199023255552 2^42 4398046511104 2^43 8796093022208 2^44 17592186044416 2^45 35184372088832 2^46 70368744177664 2^47 140737488355328 2^48 281474976710656 2^49 562949953421312 2^50 1125899906842624 2^51 2251799813685248 2^52 4503599627370496 2^53 9007199254740992 2^54 18014398509481984 2^55 36028797018963968 2^56 72057594037927936 2^57 144115188075855872 2^58 288230376151711744 2^59 576460752303423488 2^60 1152921504606846976 2^6

EDMX - Nolock extenstion class

    public static class ExtenstionMethods     {         private static TransactionScope _TransactionScope { get { return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadUncommitted }); } }         public static List<T> ToListNoLock<T>(this IEnumerable<T> query)         {             using (_TransactionScope) { return Enumerable.ToList(query); }         }         public static IEnumerable<T> AsEnumerableNoLock<T>(this IEnumerable<T> query)         {             using (_TransactionScope) { return Enumerable.AsEnumerable(query); }         }         public static T FirstOrDefaultNoLock<T>(this IEnumerable<T> query)         {             using (_TransactionScope) { return Enumerable.FirstOrDefault(query); }         }         public static T[] ToArrayNoLock<T>(this IEnumerable<T> query)         {             using (_TransactionScope) { return Enumerable.ToArray(qu

Get Entity Framework 6 use NOLOCK in its underneath SELECT statements

First of all... You should NEVER EVER use NOLOCK for each and every SQL Statement. It could compromise the integrity of your data. It’s like any other query hint a mechanism you should only use when you do something out of the ordinary. There is no way to tell the EF Provider to render the NoLock hint. If you really need to read uncommitted data you have the following option. Write your own EntityFramework Provider. Use a Command Interceptor to modify the statement before it is executed. http://msdn.microsoft.com/en-us/data/dn469464.aspx Use a TransactionScope with IsolationLevel.ReadUncommited. I know you said you do not want to use Transactions but it's the only out-of-the box way to read uncommitted data. Also it does not produce much overhead as each statement in SQL Server “implicitly” runs in a transaction. using ( new TransactionScope ( TransactionScopeOption . Required , new TransactionOptions

T-SQL: Lock a table manually for some minutes

If I understand your question correctly, it sounds like you would like to force a table lock for purposes of testing. To do that with SQL Server, you can create and run a stored procedure that will cause an exclusive table lock on the table of interest. While that lock is active, you can run the program you want to test. The following stored procedure should lock your table for 2 minutes. You can change the delay parameter to suit your needs. BEGIN TRAN SELECT 1 FROM TABLE WITH ( TABLOCKX ) WAITFOR DELAY '00:02:00' ROLLBACK TRAN GO    A general approach for doing this was described in the stackoverflow post below. The MSDN link provides some additional information on the WAITFOR statement. Original stackoverflow post Supplementary MSDN post Hope it helps.    Ref : https://stackoverflow.com/questions/25273157/t-sql-lock-a-table-manually-for-some-minutes