What is Fastexpando/Fastexpandoobject?

Asked

Viewed 225 times

14

Was reading about Dapper and I came across a feature of him called Fastexpando or Fastexpandoobject, I didn’t understand very well and I had some doubts about this feature.

Doubts

  1. What is Fastexpando/Fastexpandoobject?
  2. What is the relationship that Fastexpando/Fastexpandoobject has with Dapper?

2 answers

13


First, in the framework . NET there is the Expandoobject class, which allows the expansion of an object at runtime.

Expandoobject has several uses, one of them is in accessing the Database, storing the results of a query. The ability to change the object is very useful in this task.

Dapper, in its own definition, is a simple framework for manipulating objects in . NET, which aims to offer better performance.

Now, about Fastexpandoobject, i did not find it in the original Dapper definition (link above).

I found it in a Github repository:

where it is declared as:

private class FastExpando : System.Dynamic.DynamicObject, IDictionary<string, object>

In Sqlmapper.Cs of this repository, there is a reference to an old page:

And this page has an old Dapper package, but it also has no Fastexpando definition:

Concluding, Since the original question that left you doubtful is from 2012, I imagine that Fastexpandoobject is no longer used. And judging by name, it was meant to be faster than Expandoobject.

Researching on Expandoobject, I found another class called Betterexpando, which in its definition is "better than expanding".

And probably there must be other classes...

6

Expandoobject are dynamic objects, i.e., objects that Voce can add or remove properties at runtime.

dynamic meuCache;
meuCache.QualquerCoisa = "Qualquer coisa mesmo";
meuCache.OutraCoisa = new { FaladoSerio = true };
meuCache.MaisUmaCoisa = Enum.Empty<string>();

Today, the most popular dynamic object of . NET Framework is the Viewbag, of ASP.NET MVC.

In the case of Dapper, it uses dynamical objects to deserialize information that will come from a source where its format is unknown.

We can see your application in Dapper in your class Gridreader, method .Read(bool)

class Gridreader: The grid Reader provides interfaces for Reading Multiple result sets from a Dapper query

Ienumerable < Dynamic> Gridreader.Read(bool): Read the next grid of Results, returned as a Dynamic Object

Returning lists is always better than returning tables.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.