|
|
Browse by Tags
All Tags » DLinq
-
There is a very good resource on LINQ design guidelines that you can read more on it here:
LINQ Framework Design Guidelines (http://blogs.msdn.com/mirceat/archive/2008/03/13/linq-framework-design-guidelines.aspx)
Hope it helps,Regards
-
I figured out tonight something new in LINQ To SQL related to updating records in the database and here it is:
Suppose you have a table in SQL Server 2005, that stores data related to Article. Each article has the ArticleID, Body, Abstract, title, etc ... Also, the Body column has AllowNull set to false, so it is a must to always have a value for ...
-
In a previous post of mine (Deferred Loading in DLinq - http://bhaidar.net/cs/archive/2007/07/26/deferred-loading-in-dlinq.aspx), I explained to you how deferred loading works in DLinq. There have been some changes to the object used to enable/disable deferred loading in Orcas Beta 2! The new object used is now called ...
-
I was practicing a little bit on using Linq to Sql, and had this scenario:
Customers and Orders tables in Northwind Database. I added a new customer with no records, I wanted to apply a left outer join to get customers whose CustomerID starts with letter B such that, even if the Customer had no record in the Orders table, I wanted his/record to ...
-
I would like to invite you to check this wonderful website dedicated to LINQ (XML, Objects, database, Dataset, etc ...)
www.hookedonlinq.com
Make sure you visit it!Regards
-
Dlinq handles optimistic concurrency implicitly when exexuting SubmitChanges() method. However, you can handle the resolution of the conflict and deciding on how to solve a conflict that happened.
Usually, when two users retrieve the same record, one of them updates the record and submit changes, then anotehr user comes in and performs another ...
-
A very nice feature I find is to be able to execute a custom SQL statement in case you find the functionalities provided by the DataContext object is limited.
There are two main methods:
ExecuteQuery, which has two flavors of the ExecuteQuery method
1- Without parameters IEnumerable<Customer> results = ...
-
There are two ways in DLinq to work with Transactions. One is preferred to another.
1. Using the TransactionScope class - Preferred One
using(TransactionScope ts = new TransactionScope()) { db.SubmitChanges(); ts.Complete();}
2. Using the BeginTransaction on the SqlConnection
Product prod = q.Single(p => p.ProductId == 15);if ...
-
As you know every object retrieved using Linq to SQL is being tracked by the DataContext class for any changes that happen in the life time of the object in the application. However, this takes more processing and off course performance will be affected.Suppose one time you want to load some records from the database and bind them to a data ...
-
In an API I use in my applications at work, we have the notion of StoredQuery. We prepare a query against the database, store it as a StoredQuery, then execute the query. Why do we need to save the query expression? Maybe at some other time, we need to execute the same query, off course not neceessarily same results. So here the StoredQuery comes ...
-
Applying method filtering on the results of a DLinq query is not available. For example, suppose you want to run method named Validate on the Customer ID before returning it in the query:
var result= from c in db.customers select new {CustomerName= c.Name, ...
-
Suppose we have an entity class called Customer and it contains a property of type List of Order entity classes. Now we want to retrieve all the customers and their orders, how do we do this using Query Expression?
var results= from c in db.Customer select c;
However, this will not load the orders inside the customer entities ...
-
I have found out that DLinq internally uses Object Pooling!
Usually, when you retrieve a record from a Database Table, and then retrieve it again, another version is being created for you. This doesn't hold true for C# or VB.NET objects. When you create an instance of an object, and then request it again, the same instance is brought back ...
-
In the previous post, I have explained the idea behind Deferred Execution. What if you wanted to directly execute the query expression and bind the results to a GridView or any other Data Control? In this case, Deferred Execution is not required. The solution is simply using one of the methods defined on the Sequence class:
1. ToArray();2. ...
-
I have started recently working on C# 3.0 Enhancements and LINQ project at the same time. One of the nice features of LINQ is the ability to write Query Expressions. You can think of Query Expressions as a high-level SQL Query. You write a query as follows:
var getCustomers= from c in ...
|
|
|