コード例 #1
0
        internal QueryBuilder(ConnectorQuery connectorQuery, PropertyInfo[] properties, IReadOnlyList <MemberInfo> members = null)
        {
            this.connectorQuery = connectorQuery;

            if (members != null)
            {
                var props = new PropertyInfo[members.Count];

                for (var i = 0; i < members.Count; i++)
                {
                    for (var j = 0; j < properties.Length; j++)
                    {
                        if (properties[j].GetName() == members[i].GetName())
                        {
                            props[i] = properties[j];
                            break;
                        }
                    }
                }

                properties = props;
            }

            Properties = properties;

            PropertyGetter = new Func <T, object> [properties.Length];
            PropertySetter = new Action <T, object> [properties.Length];

            for (var i = 0; i < properties.Length; i++)
            {
                PropertyGetter[i] = properties[i].GetGetter <T>();
                PropertySetter[i] = properties[i].GetSetter <T>();
            }
        }
コード例 #2
0
        public async Task <bool> InitializeAsync(string connString, DatabaseType type, bool useTransactions = false, bool loadConnectorFromFile = true, bool printQuery = false)
        {
            Type = type;

            transactions = useTransactions;
            PrintQuery   = printQuery;

            connectionString = connString;
            connectorQuery   = new ConnectorQuery(type);

            entityBuilder = new EntityBuilder(this);

            try
            {
                connector.Load(type, loadConnectorFromFile);

                using (var connection = await CreateConnectionAsync())
                    return(connection.State == ConnectionState.Open);
            }
            catch (Exception ex)
            {
                Log.Message(LogTypes.Error, ex.ToString());

                return(false);
            }
        }
コード例 #3
0
ファイル: Connector.cs プロジェクト: Arctium/Lappa-ORM
        internal void Load()
        {
            Query = new ConnectorQuery(Settings.DatabaseType);

            switch (Settings.DatabaseType)
            {
            case DatabaseType.MSSql:
            {
                connectionType = typeof(SqlConnection);
                commandType    = typeof(SqlCommand);
                parameterType  = typeof(SqlParameter);

                break;
            }

            case DatabaseType.MySql:
            {
                connectionType = typeof(MySqlConnection);
                commandType    = typeof(MySqlCommand);
                parameterType  = typeof(MySqlParameter);

                break;
            }

            case DatabaseType.SQLite:
            {
                connectionType = typeof(SqliteConnection);
                commandType    = typeof(SqliteCommand);
                parameterType  = typeof(SqliteParameter);

                break;
            }

            case DatabaseType.PostgreSql:
            {
                connectionType = typeof(NpgsqlConnection);
                commandType    = typeof(NpgsqlCommand);
                parameterType  = typeof(NpgsqlParameter);

                break;
            }

            default:
                break;
            }

            if (connectionType == null || commandType == null || parameterType == null)
            {
                throw new TypeLoadException($"connectionType: {connectionType}, commandType: {commandType}, parameterType: {parameterType}.");
            }
        }
コード例 #4
0
 internal QueryBuilder(ConnectorQuery connectorQuery)
 {
     this.connectorQuery = connectorQuery;
 }