|
|
Browse by Tags
All Tags » Linq
-
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 ...
-
I was customizing a ListView today to show a small key gif beside each article listed to indicate that the article requires a login to be viewed based on whether the user is authenticated or not. So I decided to use inline checking to see if the current user is logged in or not and accordingly show/hide the Image. The code is like ...
-
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 ...
-
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, ...
-
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 ...
|
|
|