How to create relationships between entities in the Entity Framework Code First Approach

The Entity Framework Code First approach allows us to create a model as a plain class and then the database gets created from the domain model or entity class. In the Code First approach, the database gets created from the classes. Some advantages of the Entity Framework Code First approach include (as stated in Scott…… Continue reading How to create relationships between entities in the Entity Framework Code First Approach

What is difference between First and FirstOrDefault in LINQ?

Last week I were presenting LINQ to group of almost 100 audience. While writing query a question raised that what is difference between First and FirstOrDefault . At that time I was not very sure about answer so I asked audience to help me. One from audience answered this question. So credit of this blog…… Continue reading What is difference between First and FirstOrDefault in LINQ?

ASP.Net GridView with LinqDataSource

In this post I will walkthrough on using ASP.Net Gridview with LinqDatasource. You can bind a GridView with LinqDataSource and would able to Edit Delete View data without writing a single line of code. To see how it works , follow the steps below; Step1 Crate a ASP.Net Web Application. Step 2 Right click and…… Continue reading ASP.Net GridView with LinqDataSource

Executing SQL Query using LINQ to SQL

In this post, I will discuss how we can execute a SQL Query directly from LINQ. Explanation To execute SQL query there is a method in DataContext class called ExecuteQuery ExecuteQuery takes two input parameter 1. SQL Query as string 2. Parameters used in SQL query And it returns an IEnumerable. Example Below code will…… Continue reading Executing SQL Query using LINQ to SQL