Browse by Tags
All Tags »
Reflection (
RSS)
Introduction Thanks to Patrick Smacchia I had the chance to test NDepend 4 . I can only say: awesome! This will be the first of a series of posts on NDepend, where I will talk about my discoveries. Keep in mind that I am just starting to use it, so more...
Continuing the Dynamic LINQ series, here are some hopefuly useful methods for performing LINQ queries in IQueryable or IQueryable<T> object, with String parameters. The available methods, so far, are: GroupBy OrderBy Skip Take WhereEquals WhereNotEquals...
Remember my last post on dynamic filtering? Well, this time I'm extending the code in order to allow two levels of querying: Match type, represented by the following options: public enum MatchType { StartsWith = 0, Contains = 1 } And word match: public...
Continuing my previous posts on dynamic LINQ , now it's time for dynamic filtering. For now, I'll focus on string matching. There are four standard operators for string matching, which both NHibernate, Entity Framework and LINQ to SQL recognize: Equals...
You may recall my post on Dynamic LINQ . I said then that you had to download Microsoft's samples and compile the DynamicQuery project (or just grab my copy ), but there's another way. It turns out Microsoft included the Dynamic LINQ classes in the System...
Since .NET 3.5 brought us LINQ and expressions, I became a great fan of these technologies. There are times, however, when strong typing cannot be used - for example, when you are developing an ObjectDataSource and you need to do paging having just a...
Yep, there's still another one: FormatterServices . This one allows one to create an object without running it's constructor... it is used by some of our good friends serializers . Stopwatch watch = new Stopwatch(); for (Int32 i = 0; i Beware, though...
After I wrote this post , I come up with yet another way to create an object... Here it is: Stopwatch watch = new Stopwatch(); ConstructorInfo ci = typeof(StringBuilder).GetConstructor(new Type[0]); NewExpression expr = Expression.New(ci); Func<StringBuilder>...
Enjoy! Type type = typeof(StringBuilder); //can be any type ConstructorInfo ci = type.GetConstructor(new Type [ 0 ]); Stopwatch watch = new Stopwatch(); watch.Start(); for (Int32 i = 0; i < 100; ++i) { StringBuilder obj = Activator.CreateInstance(type...
More Posts