예제 #1
0
        public string GetFromClause(QueryOptimizer optimizer)
        {
            var sb = new StringBuilder();

            //Calculate the FROM clause
            int index = 0;

            sb.Append("FROM ");
            foreach (var fromClause in _fromLinkList)
            {
                sb.Append("[" + fromClause.Schema + "].[" + fromClause.TableName + "] AS [" + fromClause.Alias + "] ");
                if (optimizer.NoLocking)
                {
                    sb.Append("WITH (READUNCOMMITTED) ");
                }
                if (!string.IsNullOrEmpty(fromClause.LinkClause))
                {
                    sb.Append(fromClause.LinkClause + " ");
                }

                if (index < _fromLinkList.Count - 1)
                {
                    sb.AppendLine();
                    sb.Append("LEFT OUTER JOIN ");
                }

                index++;
            }
            sb.AppendLine();
            return(sb.ToString());
        }
예제 #2
0
        internal static void AddUpdate(Guid instanceKey, string sql, List <System.Data.SqlClient.SqlParameter> parameters, QueryOptimizer optimizer)
        {
            try
            {
                var newItem = new PreCacheItem
                {
                    SQL        = sql,
                    Parameters = parameters,
                    Optimizer  = optimizer,
                };

                if (!_queryUpdateCache.ContainsKey(instanceKey))
                {
                    _queryUpdateCache.TryAdd(instanceKey, new List <PreCacheItem>());
                }
                _queryUpdateCache[instanceKey].Add(newItem);
            }
            catch
            {
                throw;
            }
        }