Пример #1
0
            public object CreateAny(object value)
            {
                if (value == null)
                {
                    return(null);
                }
                var mp = TypeMapper.Create(value.GetType());
                var d  = this._ctor.GetParameters().ToDictionary(s => s.Name, s => (object)null);

                foreach (var p in mp.Properties)
                {
                    d[p.Name] = p.GetValue(value);
                }
                return(DynamicFactory.CreateConstructorHandler(_ctor)(d.Values.ToArray()));
            }
Пример #2
0
        private static IDbEngineProvider CreateProvider(string provider, string connectionString)
        {
            var type = RegisterProviders.GetOrAdd(provider, GetProviderType);

            if (type == null)
            {
                RegisterProviders.TryRemove(provider, out type);
                throw new NotSupportedException($"当前运行环境找不到名称为“{provider}”的数据库提供程序。");
            }

            var ctor = type.GetConstructor(new Type[] { DefineTypes.String });

            if (ctor == null)
            {
                throw new NotSupportedException($"当前运行环境名称为“{provider}”的数据库提供程序找不到“{type.FullName}(connectionString)” 的构造函数。");
            }
            return((IDbEngineProvider)DynamicFactory.CreateConstructorHandler(ctor)(connectionString));
        }
Пример #3
0
 public TView Create(DynamicEntityValue item) =>
 (TView)DynamicFactory.CreateConstructorHandler(_ctor)(item.NameValues.Values.ToArray());