Recent Posts

0
Comments

Lazy Loading Related Properties by zhirani

Lot of times in our application we do not perform eager loading on related entities because we don’t need to display them on the UI unless some action occurs. So we fetch those entities lazily only when we need them. However have you ever felt the need...
2
Comments

Removing entity from a Related Collection by zhirani

I have seen this misunderstanding starting to popup more often on how to delete an entity from a related collection. Suppose we have the following entity data model where a Person has many Phones identified by 1-to-many association as shown. Problem:...
0
Comments

Setting Entity Key for a view by zhirani

When you import a database view using Entity Data Model wizard,you will get an entity that has the same number of columns and data type as the view does.Suppose I have the following view in my database. When I import the view I get the following entity...
2
Comments

Search for an entity in your Entity Data Model by zhirani

Last week i discovered a feature of Entity Data Model which i have not seen extensively being promoted. I accidentally run into it because of the size of my model. If you have a large model and want to search for an entity, it becomes tedious to zoom...
1
Comments

Watch out for let operator in linq to entities by zhirani

LINQ has a really cool operator call Let that lets you declare variables inside the query. The benefit i find in using let is, it makes my query much easier to read because using Let keyword i can create a variable and assign it a calculated value. Then...
0
Comments

Small SQL improvement in Table Per Hierarchy by zhirani

Well the title of my post is somewhat disguising the actual point which I wanted to communicate. There is basically two important things that i wanted to talk about in this posting. First a slight improvement in T-SQL generation for Table Per Hierarchy...
1
Comments

Contains is smart enough to check for null by zhirani

Starting with Entity Framework 4.0 you can use Contains clause in your linq query to check if the column value matches any values in a given list. Suppose we have a model with Product and Category as shown below.   Let’s say we want to retrieve products...
1
Comments

How to share common fields between two entities that map to different tables by zhirani

The title is a mouthful so let me explain what we are trying to solve. Suppose we have two tables in the database that have common fields. When we import the tables into Entity Data Model, we want to create a base entity to contain the common fields and...
2
Comments

Entity Framework 4.0 Recipe book is officially released! by zhirani

I am very happy to announce that Entity Framework 4.0 Recipes book by Apress is officially released and is available for purchase from Amazon and other online book retailers. You can get your copy from Amazon at the address below. http://amzn.com/1430227036...
3
Comments

How to perform left join in linq to Entities by zhirani

To perform left outer join in a linq query, you would normally use DefaultIfEmpty operator. DefaultIfEmpty opreator basically gives you a default instance of an object when there is no related record found. In version 1 of Entity Framework, DefaultIfEmpty...
More Posts « Previous page - Next page »