Esempio n. 1
0
 internal IEnumerable <T> ExecuteTestScript <T>(string sql)
 {
     if (typeof(T) == typeof(int))
     {
         return((IEnumerable <T>)EfcIntSet.FromSqlRaw(sql).Select(x => x.Value).AsEnumerable());
     }
     if (typeof(T) == typeof(string))
     {
         return((IEnumerable <T>)EfcStringSet.FromSqlRaw(sql).Select(x => x.Value).AsEnumerable());
     }
     throw new NotSupportedException();
 }
Esempio n. 2
0
        public string AcquireSecurityActivityExecutionLock(int securityActivityId, string lockedBy, int timeoutInSeconds)
        {
            var query = EfcStringSet
                        .FromSqlRaw(_acquireSecurityActivityExecutionLockScript,
                                    new SqlParameter("@ActivityId", securityActivityId),
                                    new SqlParameter("@LockedBy", lockedBy ?? ""),
                                    new SqlParameter("@TimeLimit", timeoutInSeconds));

            var result = string.Empty;

            // We use foreach here instead of Single or First, because Entity Framework
            // generates an outer SELECT for those methods that result in an incorrect
            // SQL syntax.
            foreach (var item in query)
            {
                // read the first and only item and return immediately
                result = item.Value;
                break;
            }

            return(result);
        }