Skip to content

Breaking changes in PropertyMapping<T>? #177

@the-black-wolf

Description

@the-black-wolf

Hi,

upgrading to a new version just broke our code. The first issue is that IsPrimaryKey is now obsolete and will be removed, completely removing the way to dynamically discover a field that is a primary key. The new SetPrimaryKey method resolves setting the key as primary, but there is no way to retrieve which field is the key. This information is now hidden in a private _propertyRegistration we cannot access.

Another problem is that PropertyMapping no longer exposes the property Descriptor. It seems to have been removed in commit 8a9a54e, better said moved to aa registration namespace and hidden from developers.
This was a convenient way to directly access type descriptor directly from Mapping, not worrying about types in generic methods (see example below).

Generally, it has become very difficult to query the dynamically discovered ORM.
Things like this are no longer possible, to retrieve a PK value in a generic repo handler:

private static int? GetKeyValue(T c) => (int?)OrmConfiguration.GetDefaultEntityMapping<T>().GetProperties().First(p => p.IsPrimaryKey).Descriptor.GetValue(c);

There is a workaround, relying on POCO class discovery and fishing for [Key] attribute, but this seemed as more concrete solution as this is what the FstCrud uses to submit data.

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