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

GetDatasettVersions() public method

Returns all checked-in versions of the dataset datasetId.
The checked-out version, if exists, is not included in the return list.
public GetDatasettVersions ( System.Int64 datasetId ) : List
datasetId System.Int64 The identifier of the dataset.
return List
        public List<DatasetVersion> GetDatasettVersions(Int64 datasetId)
        {
            List<DatasetVersion> dsVersions = DatasetVersionRepo.Query(p =>
                p.Dataset.Id == datasetId
                && p.Dataset.Status == DatasetStatus.CheckedIn)
                .OrderByDescending(p => p.Timestamp).ToList();
            if (dsVersions != null)
            {
                //dsVersions.ForEach(p=> p.Materialize());
                return (dsVersions);
            }
            try
            {
                Dataset dataset = DatasetRepo.Get(datasetId);
                if (dataset == null)
                    throw new Exception(string.Format("Dataset {0} does not exist!", datasetId));
                if (dataset.Status == DatasetStatus.Deleted)
                    throw new Exception(string.Format("Dataset {0} is deleted", datasetId));
                if (dataset.Status == DatasetStatus.CheckedOut)
                {
                    dsVersions = dataset.Versions.Where(p => p.Status == DatasetVersionStatus.Old || p.Status == DatasetVersionStatus.CheckedIn).ToList(); //dataset.Versions.OrderByDescending(p => p.Timestamp).Skip(1).ToList(); // the first version in the list is the working copy
                    if (dsVersions != null)
                    {
                        //dsVersions.ForEach(p => p.Materialize());
                        return (dsVersions);
                    }
                }
            }
            catch
            {
                throw new Exception(string.Format("Dataset {0} does not exist or an  error occurred!", datasetId));
            }
            return (null);
        }