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);
}