Questions tagged [fastmember]

Anything related to FastMember library that provides fast access to .net fields/properties

FastMember library provides fast access to .net fields/properties.

In .NET reflection is slow... well, kinda slow. If you need access to the members of an arbitrary type, with the type and member-names known only at runtime - then it is frankly hard (especially for DLR types). This library makes such access easy and fast.

FastMember project on git

43 questions
11
votes
1 answer

How can I use FastMember to get the properties of a dynamic object?

I have the following object: dynamic person = new {Id = 1, Name = "SpiderMan"}; I need to be able to iterate through the property names e.g. "Id", "Name". I also need to be able to achieve this in the most efficient way therefore I chose to use…
MaYaN
  • 6,683
  • 12
  • 57
  • 109
8
votes
1 answer

Why does fastmember not seem faster than reflection here?

(this is via a question on twitter, re-asked here with permission) I'm trying to validate some objects quickly (to test for nulls), and I thought FastMember might be able to help - however, with the tests shown below I am seeing much worse…
Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
7
votes
1 answer

FastMember usage

I have a requirement to extract all public read-write properties that are not enumerable, unless they are a string. This is currently done by refelction and wondering if this can be done with FastMember. I tried something like the code below but it…
Berryl
  • 12,471
  • 22
  • 98
  • 182
6
votes
1 answer

How to convert an enum to int automatically via FastMember?

I'm using FastMember to convert a List to a Datatable. Some classes contain enums and this is causing problems when passing the datatables as a TVP to a stored procedure. public class MyObject { public int Id {get; set;} public SomeEnum…
Ivan-Mark Debono
  • 15,500
  • 29
  • 132
  • 263
6
votes
4 answers

Fastmember exception: Specified argument was out of the range of valid values. Parameter name: name

I've been encountering this error Specified argument was out of the range of valid values. Parameter name: name When im almost just copying the example here https://code.google.com/p/fast-member/ The error happens on the bcp.WriteToServer(reader),…
user1465073
  • 315
  • 8
  • 22
5
votes
2 answers

How can I use Fast Member to Bulk Copy data into a table with inconsistent column names?

I have a Person table with following column names: Id, Name, Dob I also have a poco as: public class Person { public int Id {get; set;} public string Name {get; set;} public string DateOfBirth {get; set;} } I am then trying: var…
MaYaN
  • 6,683
  • 12
  • 57
  • 109
4
votes
1 answer

C# Dapper and FastMember - Specified method not supported

I have a C# .NET Core 2.0 Web API project (implemented as a microservice). I am using NuGet Packages "Dapper" and "FastMember" (latest versions) in my repository layer to try to convert an IEnumerable to a DataTable via the ObjectReader that…
Chase Harrison
  • 160
  • 1
  • 10
4
votes
2 answers

FastMember column order preservation

When using TypeAccessor.Create FastMember always seems to return a list of the columns in alphabetic sorted order. Is it possible to tell it to preserve the ordering of the columns in the class? for example: var testClass = new { B = "1", A = "2"…
gmn
  • 4,199
  • 4
  • 24
  • 46
4
votes
2 answers

Assign value to Nullable using FastMember

I have successfully assigned values to Properties and nested Properties using this function private static void AssignValueToProperty(ObjectAccessor accessor, object value, string propertyLambdaString) { var index = …
Beachwalker
  • 7,685
  • 6
  • 52
  • 94
4
votes
2 answers

How to get the Attribute data of a Member with FastMember

using the FastMember library from NuGet, I am able to find all the members of a type that are decorated with a particular attribute, using this code: var accessor = TypeAccessor.Create(typeof (MyData)); var decoratedMembers =…
Ralph Shillington
  • 20,718
  • 23
  • 91
  • 154
3
votes
2 answers

FastMember: Specified argument was out of the range of valid values. Parameter name: name

I am attempting to use CsvHelper to import a CSV file and write it to my SQL database. The data imported does not belong to any predefined class and has to be determined at run time. A lot of forums pointed to using FastMember to doing this but I…
3
votes
2 answers

Can I set the property of a struct using Expressions?

I have the following method which sets the value for the given PropertyInfo on the given TInstance. This is to avoid the inefficiency of reflection. public static Action CreateSetter(PropertyInfo propertyInfo, bool…
MaYaN
  • 6,683
  • 12
  • 57
  • 109
3
votes
1 answer

FastMember ObjectReader doesn't work with inherited interfaces

I get an interface as return from a library that I have no control over: public interface IA : IB { String A { get;} } public interface IB { String B { get;} } Now when I try to run this code, I get an exception: List list =…
David S.
  • 5,965
  • 2
  • 40
  • 77
3
votes
3 answers

How to set nested property value using FastMember

I get an exception when I try to set a nested member Property using FastMember. For example when having these classes public class A { public B First { get; set; } } public class B { public string Second { get; set; } } and I want to set…
Beachwalker
  • 7,685
  • 6
  • 52
  • 94
3
votes
1 answer

Fastmember access non public properties

I wanted to replace my reflection index accessor with FastMember (https://www.nuget.org/packages/FastMember/) but stumbled across the following problem. I have the following setup: class Program { static void Main(string[] args) { …
Rand Random
  • 7,300
  • 10
  • 40
  • 88
1
2 3