Skip to content

Two properties with same name causes GetImplementingProperty to throw System.InvalidOperationException: Sequence contains no matching element #140

@DanielStout5

Description

@DanielStout5

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions