BExIS.Dlm.Services.Data.DatasetManager.AddDataView C# (CSharp) Method

AddDataView() public method

Adds a data view to the designated dataset. This method does not execute the view, but only associates it with the dataset so that later its application can be requested. A data view is the specification of a set of criteria to filter a dataset vertically and horizontally in on demand. Applying a data view on a dataset version filters its data tuples and variables if the dataset is structured. For unstructured dataset the data view can be used to pass the filtering criteria to a proper processing tool.
public AddDataView ( Dataset dataset, DataView view ) : void
dataset Dataset The dataset the view is linked to
view BExIS.Dlm.Entities.DataStructure.DataView The data view to be associated to the .
return void
        public void AddDataView(Dataset dataset, DataView view)
        {
            Contract.Requires(dataset != null);
            Contract.Requires(view != null && view.Id >= 0);
            Contract.Requires(view.Dataset == null);

            DatasetRepo.Reload(dataset);
            DatasetRepo.LoadIfNot(dataset.Views);
            int count = (from v in dataset.Views
                         where v.Id.Equals(view.Id)
                         select v
                        )
                        .Count();

            if (count > 0)
                throw new Exception(string.Format("There is a connection between dataset {0} and view {1}", dataset.Id, view.Id));

            dataset.Views.Add(view);
            view.Dataset = dataset;
            view.DataStructures.Clear();

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                // save the relation controller object which is the 1 side in 1:N relationships. in this case: View
                IRepository<DataView> repo = uow.GetRepository<DataView>();
                repo.Put(view);
                uow.Commit();
            }
        }