You can query the assets, but you have to first use the .Where(predicate bool)
, and then .FirstOrDefault
.
Following code will get you only one asset without getting all of them into a list:
public IAsset GetAssetById(string assetId)
{
var asset = _context.Assets.Where(x => x.Id.Equals(assetId)).FirstOrDefault();
if (null == asset)
{
return null;
}
return asset;
}
You can check rest of my code at the WaMediaWeb project, where I've wrapped in a Web Application almost everything you could do with Media Service.