diff --git a/InterLinq/IQueryHandler.cs b/InterLinq/IQueryHandler.cs
index 75bdf97..c9a4664 100644
--- a/InterLinq/IQueryHandler.cs
+++ b/InterLinq/IQueryHandler.cs
@@ -15,14 +15,14 @@ public interface IQueryHandler
///
/// Type of the returned .
/// Returns an .
- IQueryable Get(Type type);
+ //IQueryable Get(Type type);
///
/// Returns an .
///
/// Generic Argument of the returned .
/// Returns an .
- IQueryable Get() where T : class;
+ //IQueryable Get() where T : class;
///
/// Returns an .
diff --git a/InterLinq/InterLinqQueryHandler.cs b/InterLinq/InterLinqQueryHandler.cs
index 022e8aa..76b9440 100644
--- a/InterLinq/InterLinqQueryHandler.cs
+++ b/InterLinq/InterLinqQueryHandler.cs
@@ -24,8 +24,9 @@ public abstract class InterLinqQueryHandler : IQueryHandler
#endregion
- #region IQueryHandler Members
-
+ #region IQueryHandler Members
+
+ private Dictionary genericMethodsCache1 = new Dictionary();
///
/// Returns an .
///
@@ -33,8 +34,14 @@ public abstract class InterLinqQueryHandler : IQueryHandler
/// Returns an .
public IQueryable Get(Type type)
{
- MethodInfo getTableMethod = GetType().GetMethod("Get", new Type[] { });
- MethodInfo genericGetTableMethod = getTableMethod.MakeGenericMethod(type);
+ MethodInfo genericGetTableMethod;
+
+ if (!genericMethodsCache1.TryGetValue(type, out genericGetTableMethod))
+ {
+ MethodInfo getTableMethod = typeof (InterLinqQueryHandler).GetMethod("Get", new Type[] {});
+ genericGetTableMethod = getTableMethod.MakeGenericMethod(type);
+ genericMethodsCache1.Add(type, genericGetTableMethod);
+ }
return (IQueryable)genericGetTableMethod.Invoke(this, new object[] { });
}
@@ -66,8 +73,9 @@ public virtual bool StartSession()
public virtual bool CloseSession()
{
return true;
- }
-
+ }
+
+ private Dictionary genericMethodsCache2 = new Dictionary();
///
/// Returns a
///
@@ -75,11 +83,19 @@ public virtual bool CloseSession()
/// The name of the query.
/// Parameters for the quey.
/// Returns a .
- public virtual IQueryable Get(Type type, string name, params object[] parameters)
- {
- MethodInfo getTableMethod = GetType().GetMethod("Get", new Type[] { typeof(Type), typeof(string), typeof(object[]) });
- MethodInfo genericGetTableMethod = getTableMethod.MakeGenericMethod(type);
- return (IQueryable)genericGetTableMethod.Invoke(this, new object[] { type, name, parameters });
+ public virtual IQueryable Get(Type type, string name, params object[] parameters)
+ {
+ MethodInfo genericGetTableMethod;
+
+ if (!genericMethodsCache2.TryGetValue(type, out genericGetTableMethod))
+ {
+ MethodInfo getTableMethod = typeof(InterLinqQueryHandler).GetMethod("Get", new Type[] { typeof(string), typeof(object[]) });
+ //MethodInfo getTableMethod = typeof(InterLinqQueryHandler).GetMethods().FirstOrDefault(x=>x.Name=="Get" && x.IsGenericMethod && x.GetParameters().Count()==2);
+ genericGetTableMethod = getTableMethod.MakeGenericMethod(type);
+ genericMethodsCache2.Add(type, genericGetTableMethod);
+ }
+
+ return (IQueryable)genericGetTableMethod.Invoke(this, new object[] { name, parameters });
}
///
diff --git a/Testing/InterLinq.Tests/Client/MockClientContext.cs b/Testing/InterLinq.Tests/Client/MockClientContext.cs
index 23d93a9..4194ff9 100644
--- a/Testing/InterLinq.Tests/Client/MockClientContext.cs
+++ b/Testing/InterLinq.Tests/Client/MockClientContext.cs
@@ -39,22 +39,22 @@ private static InterLinq.IQueryRemoteHandler GetMockServerQueryHandler()
public IQueryable Suppliers
{
- get { return this.QueryHandler.Get(); }
+ get { return this.QueryHandler.Get(null, null); }
}
public IQueryable Customers
- {
- get { return this.QueryHandler.Get(); }
+ {
+ get { return this.QueryHandler.Get(null, null); }
}
public IQueryable Products
- {
- get { return this.QueryHandler.Get(); }
+ {
+ get { return this.QueryHandler.Get(null, null); }
}
public IQueryable Digits
- {
- get { return this.QueryHandler.Get(); }
+ {
+ get { return this.QueryHandler.Get(null, null); }
}
public IQueryable CustomersByCity(string cityName)