Exemplo n.º 1
0
        public override IReadOnlyCollection <Row> Initialize()
        {
            var connectionString = Db.Config.DatabaseConnectionString;

            Schema = new RowSchema(connectionString, View.ViewName, PrimaryKeyColumns);

            CreateCacheTable(connectionString, View.ViewName, _cacheTableName, PrimaryKeyColumns);
            //Db.Config.DatabaseConnectionString.CreateMemoryViewCache(_view.ViewName,_cacheTableName,PrimaryKeyColumns);
            DisposeHelper.Attach(() => connectionString.WithConnection(con => con.ExecuteNonQuery($"DROP TABLE {_cacheTableName}")));

            _mergeSelectViewChanges = new MergeSelectViewChanges(_cacheTableName, View.ViewName, Schema.ColumnNames.Values.ToArray(), PrimaryKeyColumns, PrimaryKeyColumns);

            List <Row> rows = new List <Row>();

            connectionString.WithReader($"SELECT * FROM {_cacheTableName}", r =>
            {
                while (r.Read())
                {
                    rows.Add(Schema.ReadRow(r));
                }
            });
            return(rows);
        }