Ejemplo n.º 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>();
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
0
        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}.");
            }
        }
Ejemplo n.º 4
0
 internal QueryBuilder(ConnectorQuery connectorQuery)
 {
     this.connectorQuery = connectorQuery;
 }