public void TestQueryCacheOverflow(string context)
        {
            var oldValue = Configuration.Linq.DisableQueryCache;

            var actions = new Action <ITestDataContext> [100 + 50];

            var dbParam     = Expression.Parameter(typeof(ITestDataContext), "db");
            var tableMethod = MemberHelper.MethodOf(() => DataExtensions.GetTable <LinqDataTypes2>(null));
            var table       = Expression.Call(tableMethod, dbParam);

            var recordParam = Expression.Parameter(typeof(LinqDataTypes2), "record");

            var where = MemberHelper.MethodOf(() => Queryable.Where <LinqDataTypes2>(null, (Expression <Func <LinqDataTypes2, bool> >)null));

            var toListMethod = MemberHelper.MethodOf(() => Enumerable.ToList <LinqDataTypes2>(null));

            for (var i = 0; i < actions.Length; i++)
            {
                var predicateBody = Expression.Equal(Expression.PropertyOrField(recordParam, "ID"), Expression.Constant(i));
                var predicate     = Expression.Lambda <Func <LinqDataTypes2, bool> >(predicateBody, recordParam);
                var body          = Expression.Call(where, table, predicate);

                body = Expression.Call(toListMethod, body);

                actions[i] = Expression.Lambda <Action <ITestDataContext> >(body, dbParam).Compile();
            }

            try
            {
                Configuration.Linq.DisableQueryCache = false;

                TestIt(context, "TestQueryCacheOverflow", 10, actions, CacheMode.CacheEnabled);
            }
            finally
            {
                Configuration.Linq.DisableQueryCache = oldValue;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Returns queryable source for specified mapping class for current connection, mapped to table expression or function.
 /// It could be used e.g. for queries to table-valued functions or to decorate queried table with hints.
 /// </summary>
 /// <typeparam name="T">Mapping class type.</typeparam>
 /// <param name="instance">Instance object for <paramref name="methodInfo"/> method or null for static method.</param>
 /// <param name="methodInfo">Method, decorated with expression attribute, based on <see cref="LinqToDB.Sql.TableFunctionAttribute"/>.</param>
 /// <param name="parameters">Parameters for <paramref name="methodInfo"/> method.</param>
 /// <returns>Queryable source.</returns>
 public ITable <T> GetTable <T>(object instance, MethodInfo methodInfo, params object[] parameters)
     where T : class
 {
     return(DataExtensions.GetTable <T>(this, instance, methodInfo, parameters));
 }