I've run into a strange issue. I have a generic extension on interface .IDbGroups which defines a Groups property, but when it's invoked I get an InvalidOperationException.
Is there something I should know about about generic extensions and implementation?
Code:
public interface IDbGroups
{
[Required]
string Groups { get; set; }
}
public interface ISetting : IAssetsDbBase, IDbGroups
{
...
}
public sealed class Setting : AssetsDbBase, ISetting
{
...
public string Groups { get; set; }
...
public const string DefaultGroupName = "Assets";
}
[Expandable(nameof(Predicates.InGroupsImpl))]
public static MatchTypes DbInGroups<TEntity>(this TEntity item, string values) where TEntity : class, IDbGroups
=> DbUtility.ListMatches(item.Groups, values);
public static Expression<Func<TEntity, MatchTypes>> InGroupsImpl<TEntity>(string values) where TEntity : class, IDbGroups
=> e => DbUtility.ListMatches(e.Groups, values)
This line:
cache.Settings = await db.GetWorker<Setting>().WhereAsync(s => s.AppId.Equals(cache.App.Id) || s.AppId == null && s.DbInGroups(Setting.DefaultGroupName).Equals(MatchTypes.All));
Causes follow exception:
Inner Exception 1:
InvalidOperationException: No generic method 'InGroupsImpl' on type 'SLT.Assets.Extensions.LINQExtensions' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.
Any suggestions would be great, I can't figure out why this happens. The error remains even if I remove
s.DbInGroups(Setting.DefaultGroupName).Equals(MatchTypes.All))
It accours when I query DbSet<Setting>
Weird