Ejemplo n.º 1
0
 public static DynamicMethod GetObjectToParamListMethod <TParam>(Type objType) where TParam : DbParameter
 {
     return(_ObjectToParamListMethodCache.GetValue(objType.TypeHandle, () =>
     {
         return EmitUtil.CreateObjectToParamListMethod <TParam>(objType);
     }));
 }
Ejemplo n.º 2
0
 public static DynamicMethod GetConvertToListMethod <T>()
 {
     return(_ConvertToListMethodCache.GetValue(typeof(T).TypeHandle, () =>
     {
         return EmitUtil.CreateTableToListMethod <T>();
     }));
 }
Ejemplo n.º 3
0
 public static DynamicMethod GetConvertToEntityMethod <T>()
 {
     return(_ConvertDataRowToEntityMethodCache.GetValue(typeof(T).TypeHandle, () =>
     {
         return EmitUtil.CreateDataRowToEntityMethod <T>();
     }));
 }
Ejemplo n.º 4
0
        public static DynamicMethod GetObjectToParamListMethod <TParam>(Type objType) where TParam : DbParameter
        {
            ConcurrentDictionary <RuntimeTypeHandle, DynamicMethod> objectToParamListMethod;

            _ObjectToParamListMethodCache.TryGetValue(objType.TypeHandle, out objectToParamListMethod);
            if (objectToParamListMethod != null)
            {
                DynamicMethod method;
                objectToParamListMethod.TryGetValue(typeof(TParam).TypeHandle, out method);
                if (method == null)
                {
                    method = EmitUtil.CreateObjectToParamListMethod <TParam>(objType);
                    objectToParamListMethod.TryAdd(typeof(TParam).TypeHandle, method);
                    _ObjectToParamListMethodCache[objType.TypeHandle] = objectToParamListMethod;
                }
                return(method);
            }
            else
            {
                objectToParamListMethod = new ConcurrentDictionary <RuntimeTypeHandle, DynamicMethod>();
                DynamicMethod method = EmitUtil.CreateObjectToParamListMethod <TParam>(objType);
                objectToParamListMethod.TryAdd(typeof(TParam).TypeHandle, method);
                _ObjectToParamListMethodCache[objType.TypeHandle] = objectToParamListMethod;
                return(method);
            }
        }