private void ReadVisibleTables()
        {
            lock (commitLock) {
                var tables = StateStore.GetVisibleList();

                // For each visible table
                foreach (var resource in tables)
                {
                    var tableId    = resource.TableId;
                    var sourceName = resource.SourceName;

                    // TODO: add a table source type?

                    // Load the master table from the resource information
                    var source = LoadTableSource(tableId, sourceName);

                    if (source == null)
                    {
                        throw new InvalidOperationException(String.Format("Table {0} was not found.", sourceName));
                    }

                    source.Open();

                    tableSources.Add(tableId, source);
                }
            }
        }
Example #2
0
        public IEnumerable <ITableSource> GetTableSources()
        {
            lock (commitLock) {
                var list = StateStore.GetVisibleList();

                return(list.Select(x => GetTableSource(x.TableId)));
            }
        }
        internal ITransaction CreateTransaction(IsolationLevel isolation)
        {
            var thisCommittedTables = new List <TableSource>();

            // Don't let a commit happen while we are looking at this.
            lock (commitLock) {
                int thisCommitId       = CurrentCommitId;
                var committedTableList = StateStore.GetVisibleList();
                thisCommittedTables.AddRange(committedTableList.Select(resource => GetTableSource(resource.TableId)));

                // Create a set of IIndexSet for all the tables in this transaction.
                var indexInfo = (thisCommittedTables.Select(mtable => mtable.CreateIndexSet())).ToList();

                // Create a context for the transaction to handle the isolated storage of variables and services
                var context = DatabaseContext.CreateTransactionContext();

                // Create the transaction and record it in the open transactions list.
                return(new Transaction(context, Database, thisCommitId, isolation, thisCommittedTables, indexInfo));
            }
        }