Contents tagged with LINQ
-
Using Generated Methods Instead of Reflection
It is a common thing to say that reflection is slow.You will find tons of posts saying this, and I generally tend to agree to them, although in most cases we generally don’t need to care that much – in fact, so many libraries and frameworks that we rely on daily depend on it!
-
Performance in .NET – Part 1
Updated: thanks, Paulo Morgado!
-
Detecting Default Values of Value Types
I don’t know if this happened to you: the need to find out if some instance of a class is the class’ default value. For reference types – which include nullables -, it is always null, and for value types, it is the value that you get if you do not initialize a field of that type or if you call its default parameterless constructor – false for Boolean, 0 for numbers, the 0 member of an enumeration, etc. So, the problem is, how can we tell if some instance represents this default value, dynamically, that is, for any value type, not just a specific one.
-
Lesser-Known NHibernate Features: Filtering an Unloaded Collection
Suppose you have an entity with a collection of other entities (one to many, many to many); this collection is normally represented by some property implementing IEnumerable<T>, or one some more specific interface.
-
ASP.NET NHibernateDataSource
A long, long time ago, I wrote a NHibernateDataSource control. Back then, it was based in the first LINQ provider for NHibernate, and a long has happened since. Now, I decided to give it another go!
-
Entity Framework Pitfalls: Registering Custom Database Functions for LINQ
Like I said in my previous post, it’s not enough to add a DbFunctionAttribute attribute to a method to have it call a database function. If the function is not a built-in one, it will not be registered in the Entity Framework provider manifest for SQL Server, so it will require registration in the model. You might think, just by looking at the methods in SqlFunctions that all that it took was to add this attribute, but you would be wrong.
-
Registering SQL Server Built-in Functions to Entity Framework Code First
It is possible to register custom functions that exist in the database so that they can be called by Entity Framework Code First LINQ queries.
-
Getting the SQL from a LINQ Query in NHibernate
In case you ever want to have a look at the generated SQL before it is actually executed, you can use this extension method:
-
Mapping Non-Public Members With Entity Framework Code First
This is a common request, and really makes sense; we need to use LINQ expressions and a bit of reflection magic. First, an helper function for returning an expression that points to a member:
-
Caching LINQ Queries
Some days ago I wrote a post on comparing LINQ expressions where I shared my discoveries and general discontent on how difficult it is do right. The reason I was looking into it was because I wanted to write a LINQ query caching mechanism.