Taswar Bhatti
The synonyms of software simplicity
Category: .NET
automapper

In Part 4 we will see how we can use projection to map inner objects for example a DateTime field. Again our domain and Dto (Data Transfer Object) looks like

We will map the PurchaseDate in the Domain Object to our Dto PurchaseHour and Purchase Minute.

As you can see the View now […]

automapper

In this part we learn about Nested Mapping in Automapper and we will use the same OrderDto Object that we had previously but we will let Automapper to map the inner objects. Once again here is the Domain Objects First

The Dto (Data Transfer Object) look like

This time when we map Order […]

automapper

In this part I will be showing how Automapper uses flattening by convention. If we look at our OrderDto we will see that it has a IEnumerable of OrderItemsDto and also something called OrderNumber. This is the type of object we want to send to our presentation layer.

Compare that to our domain object […]

automapper

Recently I gave a talk on Automapper in Ottawa .Net Community, so I though I would post the main ideas of the presentation here also. The demo was based on an Order System where there were just 3 tables/classes, “Order”, “Customer” and “OrderItems” From the diagram we can see that a Customer has a Bio […]

linq

You are here beacause you probably got a Linq error, specifically Operator ‘==’ cannot be applied to operands of type ‘System.Collections.Generic.KeyValuePair‘ and ‘‘ So if you wish to do something like this to KeyValuePair using Linq

You will get this error Operator ‘!=’ cannot be applied to operands of type ‘System.Collections.Generic.KeyValuePair‘ and ‘‘ Since […]

linq

So sometimes you will get these strange errors or exceptions when using Linq Sequence contains no matching element For example if you use

This will throw InvalidOperationException with Sequence contains no matching element. But if you use

Which will return you a null if its not found then you can check if the […]

asp.net

There are tones of blog post out there on how to redirect http to https. As in when a user request for http://myserver.com/Login.aspx they will be redirected to https://myserver.com/Login.aspx One can do it with IIS but I find that way a bit ugly since you have to create another site and set the 403 to […]

design patterns

Null Pattern Last time I blogged about “Learn the Null Pattern“, but I forgot to mention one thing about the Null Pattern. That is you have to be mindful of it. For example

The code looks okay but what if the GetEmployee method actually returns a NullEmployee? Well that would still be okay, since […]

UA-4524639-2