Recently, we switched to EF 6, and we started using asynchronous EF commands. For example, in my repository, I have the following method:
public async Task<IEnumerable<TEntity>> GetRangeAsync(int skip, int take)
{
var entities = this.AddIncludes(this.DbContext.Set<TEntity>())
.OrderBy(this.SortSpec.PropertyName)
.Skip(skip)
.Take(take)
.ToListAsync();
return await entities;
}
Now I need to change the user interface to receive async data. Below is my user interface class; This class is associated with WPF.
public sealed class RepositoryCollectionView<TEntity, TEntityViewModel> : IList<TEntityViewModel>,
ICollectionView,
IEditableCollectionView,
IComparer
...
public TEntityViewModel this[int index]
{
get
{
return await this.GetItem(index).Result;
}
set
{
throw new NotSupportedException();
}
}
...
...
...
Problem: in the user interface, I created a new method called GetItemAsync (index), and I need to call this method from the Indexer; When I write the async keyword for the indexer as follows:
public async TEntityViewModel this[int index]I get the following error : "async modifier" is not valid for this element "
Any idea? Any help would be greatly appreciated!