Tag: LINQ
-
Using O/R designer to bind a Windows Form in LINQ
In this post I will show you, how you could bind a Windows Form with Entity created by O/R designer. Essentially we are going to create a DataSource using generated entity of O/R designer. I assume that, 1. You have created Windows Application project. 2. You have created Datacontext and entity class using LINQ to…
-
Turning off Pluralization of classes in LINQ to SQL O/R designer
In this quick post, I will show you how you could avoid pluralization of classes in LINQ to SQL Step1 Open visual studio and click on Tool from Menu. Then select Options Step 2 Select Database Tools tab Step 3 Now choose O/R designer option from Database tool tab Step 4 Change Enabled to False.…
-
Resolving Concurrency conflicts in LINQ
While performing database operation, one major thing need to be taken care of is Concurrency Conflicts. Concurrency conflict can happen when two sources are try to modify database at the same time. Let us understand conflict in LINQ with an example, From above diagram you can infer that, essentially there are three steps involved in…
-
Logging in LINQ to SQL
It is very common that may come in your mind that, how we can see SQL query being generated at the back end for LINQ query. Assume you have a LINQ as below, If you want to view SQL query generated for above LINQ on console screen you need to add just one line of…
-
Inserting/Updating Record on related entities using LINQ
It is a very common scenario that you need to insert rows in related tables using LINQ. Assume you have two tables as below, Insert a Person with no Office Assignment If you have requirement to insert a Person without any Office Assignment then it is quiet straight forward task like below If you need…
-
DataContext in LINQ
To make a communication with Database a connection must be made. In LINQ this connection is created by DataContext. Essentially Data Context class performs below two tasks Create connection to database. It submits and retrieves object to database. Converts objects to SQL queries and vice versa You can say, it acts as exactly the same…
-
Connection string in LINQ
It is very common that you come across scenario when at run time you need to change the database server and so the connection string is used in your LINQ. This may come as requirement, if you are moving your application from dev server to staging and from staging to production. There are two ways…
-
Reading XML file through LINQ: few Tips
In this post I will discuss how could be read XML file using LINQ. We will see some tips as well. Let us say we have XML file as below, this file is stored on D drive. This XML contains information about books. Data.Xml Fetching all the Books To fetch all the Books,…