예제 #1
0
        public static dynamic GetQueryableOfDerivedType(this EntityObjectStore.LocalContext context, Type type)
        {
            Type       mostBaseType = context.GetMostBaseType(type);
            MethodInfo mi           = typeof(ObjectContextUtils).GetMethod("GetObjectSetOfType").MakeGenericMethod(type, mostBaseType);

            return(InvokeUtils.InvokeStatic(mi, new object[] { context }));
        }
예제 #2
0
        public static dynamic GetObjectSet(this EntityObjectStore.LocalContext context, Type type)
        {
            Type       mostBaseType = context.GetMostBaseType(type);
            MethodInfo mi           = context.WrappedObjectContext.GetType().GetMethod("CreateObjectSet", Type.EmptyTypes).MakeGenericMethod(mostBaseType);
            dynamic    os           = mi.Invoke(context.WrappedObjectContext, null);

            os.MergeOption = context.DefaultMergeOption;
            return(os);
        }
예제 #3
0
        public static ObjectQuery GetObjectSet(this EntityObjectStore.LocalContext context, Type type)
        {
            var mostBaseType = context.GetMostBaseType(type);
            var mi           = context.WrappedObjectContext.GetType().GetMethod("CreateObjectSet", Type.EmptyTypes).MakeGenericMethod(mostBaseType);
            var os           = (ObjectQuery)mi.Invoke(context.WrappedObjectContext, null);

            os.MergeOption = context.DefaultMergeOption;
            return(os);
        }
예제 #4
0
        public static dynamic CreateQuery(this EntityObjectStore.LocalContext context, Type type, string queryString, params ObjectParameter[] parameters)
        {
            Type       mostBaseType = context.GetMostBaseType(type);
            MethodInfo mi           = context.WrappedObjectContext.GetType().GetMethod("CreateQuery").MakeGenericMethod(mostBaseType);
            var        parms        = new List <object> {
                queryString, new ObjectParameter[] {}
            };

            dynamic os = mi.Invoke(context.WrappedObjectContext, parms.ToArray());

            if (type != mostBaseType)
            {
                dynamic ot = os.GetType().GetMethod("OfType").MakeGenericMethod(type);
                os = ot.Invoke(os, null);
            }

            return(os);
        }