zplCore.comzplCore.com

PropertyPath

public static class PropertyPath

Fast, cached access to (nested) members by name: "Name", "Customer.Address.City", "Items[0].Name", "[2]". Works on POCOs (compiled getters), IDictionary/IReadOnlyDictionary with string keys (incl. ExpandoObject), non-generic IDictionary, DataRow, System.Text.Json JsonElement and JsonNode/JsonObject/JsonArray, and string indexers. Keys are matched exactly first, then case-insensitively. JSON scalars are returned as CLR values (string, long, decimal/double, bool, null).

Thread-safe: the getter and path caches are concurrent dictionaries (bounded by the number of type/path pairs used). PropertyPath.RegisterUnwrapper` should be called at start-up. Under NativeAOT a POCO member that cannot be found throws MissingMemberException instead of returning null: its reflection metadata was probably trimmed (keep the model with TrimmerRootAssembly; docs-internal/aot.md).

Methods

Method SignatureReturnsDescription
static # Get(object obj, string path)object
static # RegisterUnwrapper<TWrapper>(Func<TWrapper, object> unwrap)voidRegisters a converter for wrapper value types of document databases, e.g. PropertyPath.RegisterUnwrapper<BsonValue>(v => v.RawValue) for LiteDB.