QuickMember 2.0.0
dotnet add package QuickMember --version 2.0.0
NuGet\Install-Package QuickMember -Version 2.0.0
<PackageReference Include="QuickMember" Version="2.0.0" />
<PackageVersion Include="QuickMember" Version="2.0.0" />
<PackageReference Include="QuickMember" />
paket add QuickMember --version 2.0.0
#r "nuget: QuickMember, 2.0.0"
#:package QuickMember@2.0.0
#addin nuget:?package=QuickMember&version=2.0.0
#tool nuget:?package=QuickMember&version=2.0.0
QuickMember
Fast by-name member access for .NET. Based on FastMember by Marc Gravell.
What is this?
In .NET, reflection is slow. If you need access to the members of an arbitrary type, with the type and member names known only at runtime, it is frankly hard (especially for DLR types). This library makes such access easy and fast by generating IL at runtime that approaches the speed of direct compiled property access.
Installation
dotnet add package QuickMember
Targets: netstandard2.0, net8.0, net10.0
Usage
Type-level access (best for many objects of the same type)
var accessor = TypeAccessor.Create(typeof(MyType));
while (/* some loop of data */)
{
accessor[obj, "Name"] = rowValue;
}
Object-level access (wraps a single instance)
var wrapped = ObjectAccessor.Create(obj); // works with static and DLR types
Console.WriteLine(wrapped["Name"]);
As an IDataReader (for SqlBulkCopy, DataTable, TVPs)
Load a DataTable from a sequence of objects:
IEnumerable<Customer> data = GetCustomers();
var table = new DataTable();
using (var reader = ObjectReader.Create(data))
{
table.Load(reader);
}
Bulk-insert into a database:
using var bcp = new SqlBulkCopy(connection);
using var reader = ObjectReader.Create(data, "Id", "Name", "Email");
bcp.DestinationTableName = "Customers";
bcp.WriteToServer(reader);
Non-public members
var accessor = TypeAccessor.Create(typeof(MyType), allowNonPublicAccessors: true);
accessor[obj, "InternalProp"] = value;
Member inspection
var accessor = TypeAccessor.Create(typeof(MyType));
var members = accessor.GetMembers();
foreach (var member in members)
{
Console.WriteLine($"{member.Name}: {member.Type} (CanRead={member.CanRead}, IsIndexer={member.IsIndexer})");
}
Column ordering with OrdinalAttribute
public class Customer
{
[Ordinal(2)]
public string Email { get; set; }
[Ordinal(0)]
public int Id { get; set; }
[Ordinal(1)]
public string Name { get; set; }
}
Benchmarks
Accessor Performance (get + set per call)
BenchmarkDotNet v0.15.8, .NET 10.0.5, AMD Ryzen 9 7950X
| Method | Mean | Allocated |
|------------------------- |-----------:|----------:|
| Static C# (baseline) | 0.163 ns | 0 B |
| Dynamic C# | 4.379 ns | 0 B |
| TypeAccessor | 9.983 ns | 0 B |
| ObjectAccessor | 10.533 ns | 0 B |
| PropertyInfo | 14.073 ns | 0 B |
| PropertyDescriptor | 47.308 ns | 32 B |
| TypeAccessor.CreateNew | 3.392 ns | 24 B |
| Activator.CreateInstance | 8.742 ns | 24 B |
Construction & Memory
| Method | Mean | Allocated |
|----------------------------- |------------:|----------:|
| GetMembers (cached) | 0.608 ns | 0 B |
| ObjectAccessor.Create | 12.110 ns | 120 B |
| ObjectReader.Create (8 cols) | 348.893 ns | 1,000 B |
| ObjectReader.Read+GetValues | 292.711 ns | 1,240 B |
| GetSchemaTable | 2,608.989 ns| 11,832 B |
Changes from FastMember
QuickMember is a derivative work of FastMember (Apache-2.0). Key changes:
Features
Member.IsIndexer-- detect indexer properties to avoid exceptions when iterating all members- Non-public property discovery --
TypeAccessor.Create(type, allowNonPublicAccessors: true)now finds internal/private properties (not just non-public getters/setters on public properties) IsKeycolumn inGetSchemaTable-- enablesObjectReaderas a table-valued parameter source forSqlParameter
Ahead of Time
This library emits IL at runtime. It will not work in constrained AOT environments (iOS, Unity IL2CPP, NativeAOT without rd.xml configuration).
License
Apache-2.0. See LICENSE and NOTICE for original attribution.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.7.0)
- System.Reflection.Emit (>= 4.7.0)
- System.Reflection.Emit.Lightweight (>= 4.7.0)
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 77 | 4/3/2026 |