Paulo Morgado

.NET Development & Architecture

This Blog

Syndication

Search

Tags

News

Unit Test Today! Get Typemock Isolator!

Projects

Books

 

Visitors

Visitor Locations

Community

Email Notifications

Archives

Profile

Disclaimer

The opinions and viewpoints expressed in this site are mine and do not necessarily reflect those of Microsoft, my employer or any community that I belong to. Any code or opinions are offered as is. Products or services mentioned are purchased by me, made available to me by my employer or the manufacturer/vendor which doesn't influence my opinion in any way.

Browse by Tags

All Tags » LINQ » C# (RSS)
Creating Property Set Expression Trees In A Developer Friendly Way
In a previous post I showed how to create expression trees to set properties on an object. The way I did it was not very developer friendly. It involved explicitly creating the necessary expressions because the compiler won’t generate expression trees...

Posted Wed, Jan 12 2011 2:36 by Paulo Morgado | 1 comment(s)

LINQ: Implementing The SkipLastWhile Operator
Following my last posts ( > )( > ), in this post I’ll introduce the implementation of the SkipLastWhile operator. The SkipLastWhile returns all but the last contiguous elements from a a sequence that satisfy the specified criteria and is implemented...

Posted Wed, Oct 20 2010 1:00 by Paulo Morgado | 4 comment(s)

LINQ: Implementing The SkipLast Operator
Following my last post , in this post I’ll introduce the implementation of the SkipLast operator. The SkipLast operator returns all but a specified number of contiguous elements from the end of a sequence and is implemented as the SkipLast extension method...

Posted Wed, Oct 20 2010 0:59 by Paulo Morgado | with no comments

LINQ: Introducing The Skip Last Operators
After having introduced the TakeLast operators ( > )( > )( > ), it makes sense to introduce their duals: the SkipLast operators. Name Description Example SkipLast<TSource>(IEnumerable<TSource>) Returns all but a specified number of...

Posted Wed, Oct 20 2010 0:58 by Paulo Morgado | with no comments

LINQ: Implementing The TakeLastWhile Operator
Following my last posts ( > )( > ), in this post I’ll introduce the implementation of the TakeLastWhile operator. The TakeLastWhile operator returns last contiguous elements from a sequence that satisfy the specified criteria and is implemented...

Posted Mon, Oct 18 2010 0:26 by Paulo Morgado | with no comments

LINQ: Implementing The TakeLast Operator
Following my last post , in this post I’ll introduce the implementation of the TakeLast operator. The TakeLast operator returns a specified number of contiguous elements from the end of a sequence and is implemented as the TakeLast extension method :...

Posted Mon, Oct 18 2010 0:26 by Paulo Morgado | with no comments

Hydrating Objects With Expression Trees - Part III
To finalize this series on object hydration, I’ll show some performance comparisons between the different methods of hydrating objects. For the purpose of this exercise, I’ll use this class: class SomeType { public int Id { get ; set ; } public string...

Posted Wed, Aug 18 2010 2:27 by Paulo Morgado | 2 comment(s)

Hydrating Objects With Expression Trees - Part II
In my previous post I showed how to hydrate objects by creating instances and setting properties in those instances. But, if the intent is to hydrate the objects from data, why not having an expression that does just that? That’s what the member initialization...

Posted Mon, Aug 16 2010 23:19 by Paulo Morgado | 2 comment(s)

Hydrating Objects With Expression Trees - Part I
After my post about dumping objects using expression trees , I’ve been asked if the same could be done for hydrating objects. Sure it can, but it might not be that easy. What we are looking for is a way to set properties on objects of an unknown type...

Posted Mon, Aug 16 2010 1:55 by Paulo Morgado | 2 comment(s)

Mastering Expression Trees With .NET Reflector
Following my last post , I received lots of enquiries about how got to master the creation of expression trees . The answer is: .NET Reflector On that post I needed to to generate an expression tree for this expression: Expression < Func < object...

Posted Fri, Aug 6 2010 1:40 by Paulo Morgado | 1 comment(s)

Dumping Objects Using Expression Trees
No. I’m not proposing to get rid of objects. A colleague of mine was asked if I knew a way to dump a list of objects of unknown type into a DataTable with better performance than the way he was using. The objects being dumped usually have over a...

Posted Tue, Aug 3 2010 1:36 by Paulo Morgado | 2 comment(s)

LINQ: Enhancing Distinct With The SelectorEqualityComparer
On my last post , I introduced the PredicateEqualityComparer and a Distinct extension method that receives a predicate to internally create a PredicateEqualityComparer to filter elements. Using the predicate, greatly improves readability, conciseness...

Posted Fri, Apr 9 2010 2:32 by Paulo Morgado | 7 comment(s)

Filed under: , , , , ,

LINQ: Enhancing Distinct With The PredicateEqualityComparer
Today I was writing a LINQ query and I needed to select distinct values based on a comparison criteria. Fortunately, LINQ’ s Distinct method allows an equality comparer to be supplied, but, unfortunately, sometimes, this means having to write custom equality...

Posted Thu, Apr 8 2010 2:18 by Paulo Morgado | 11 comment(s)

Filed under: , , , , ,

Playing With LINQ: Getting Interface Property Implementations
Today, my friend Nuno was writing some code to get the PropertyInfo s of a class implementation of an interface. Given this interface: public interface ISomeInterface { int IntProperty { get ; set ; } string StringProperty { get ; } void Method(); } and...

Posted Wed, Jan 27 2010 2:22 by Paulo Morgado | with no comments

How To Set Elements Of An Array Of A Private Type Using Visual Studio Shadows
Visual Studio uses Publicize to create accessors public for private members and types of a type. But when you try to set elements of a private array of elements of a private type, things get complicated. Imagine this hypothetic class to test: public static...

Posted Tue, Jan 19 2010 0:26 by Paulo Morgado | with no comments

LINQ To SQL Tips & Tricks: String Operations
LINQ brought developers a very user friendly and domain independent style of writing queries. The fact that the way queries are written is domain independent doesn’t mean that any query will compile the same way or even run the same way. You’ll always...

Posted Tue, Oct 13 2009 1:51 by Paulo Morgado | with no comments

LINQ With C# Book Is Finally Out
It’s finally out! The LINQ Com C# (LINQ With C#) book that Luís and I wrote is out. Well, mostly Luís than I. This book, published by FCA , is targeted at anyone that already knows C# 2.0 and wants to know learn the new features introduced with C# 3.0...

Posted Mon, May 18 2009 0:39 by Paulo Morgado | with no comments

Filed under: , , , , ,

LINQ With C# Book
Luís just broke the news on our LINQ with C# book. I was honored with the invitation from Luís to write this book with him for FCA , for which he has already published a few books [ ^ ] [ ^ ] [ ^ ] before. This will be an entry level book in Portuguese...

Posted Mon, Sep 22 2008 0:42 by Paulo Morgado | 1 comment(s)

Filed under: , , , , ,

More On Another Way For Using The “using” Keyword
In the past I presented another possible use for the using keyword: as hints on LINQ . I’ve been giving some thought about this lately and refined my proposal. var q = from person in personCollection using MyEnumerableExtensions group person by person...

Posted Mon, Aug 11 2008 1:47 by Paulo Morgado | 2 comment(s)

Filed under: , , , , ,

C# And Visual Basic Generate Different Expression Trees
(This was pointed out to me by Frans Bouma and explained by Jon Skeet ) Imagine you have this set of classes: public class A { public virtual string P { get { return "A" ; } } } public class B : A { } public class C : B { public override string...

Posted Mon, Aug 4 2008 1:23 by Paulo Morgado | 1 comment(s)

More Posts Next page »