Simplification of my setup:
public interface IStringId { string Id { get; } }
public class Item
{
public int Id { get; set ; }
string IStringId.Id => Id.ToString();
}
public Task<Item> GetItem(string id) => db.Items.FirstOrDefaultAsync(x => x.Id == id);
GetItem method throws InvalidOperationException when UseProjectables() is called, but works fine otherwise.
I see that TypeExtensions.GetConcreteProperty is called with propertyInfo being the string Id property from IStringId
DeclaringType is an interface, so it calls GetImplementingProperty, but it's looking for a property that isn't declared on this class, so this .First throws the InvalidOperationException:
return derivedProperties.First(propertyInfo.GetMethod == accessor
? p => p.GetMethod == implementingAccessor
: p => p.SetMethod == implementingAccessor);