Browse by Tags

All Tags » LINQ (RSS)
You may have gotten this error when trying to update data, as I recently did. After reading up on the subject, I found this which helped: http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/2bb60aae-7510-4eae-846b-1dad25f2f181 By establishing...
Posted by bmains | with no comments
Filed under:
I got this error when setting up some LINQ to XML code and I couldn't figure out why I kept getting this error as it made no sense. After doing a quick search, I realized my root element was this: var o = new XElement("statement", query...
Posted by bmains | with no comments
Filed under: ,
You may have already noticed that it's harder to debug errors that occur within a Lambda expression. For instance, if you have this Lambda expression: var entries = collection.Where(i => i.EndDate.Value >= new DateTime(2008, 2, 1)); Notice the...
Posted by bmains | with no comments
Filed under: ,
You may have gotten this error when using LINQ to SQL. I personally hate this error, but surprisingly enough, out of 2 years of using LINQ to SQL, this is the first time I've gotten this (2 years later, I mean). This error happens in this scenario...
Posted by bmains | with no comments
Filed under:
You've made some changes to your web site, and nothing comes up. Instead, you see some action going on in the status bar, where the status bar freaks out. What in the world is going on, you might ask? Certain types of changes to the application cause...
Posted by bmains | with no comments
Filed under: ,
If you use LINQ to SQL (which if you're considering it, you should consider going to the ADO.NET Entity Framework), the DataContext object that's automatically generated for you has a variety of constructors that you can use. One of the more important...
Posted by bmains | with no comments
Filed under:
I got this error when creating a new detached object. The issue was that a related object wasn't detached from the ObjectContext, but the detached object referenced an attached one. By detaching the related object when I assigned to the new object...
Posted by bmains | with no comments
Filed under: ,
If you have developed applications with LINQ to SQL, you know that one of the features of these objects are that they are aware of the DataContext they were created in. This can have issues in ASP.NET if you do not cache the DataContext it belonged to...
Posted by bmains | with no comments
Filed under:
To a point, LINQ to SQL works well with unit testing. When the LINQ-to-SQL objects are in a detached state (either not submitted to the database, or detached through the detach command) and there isn't a chance of accidentally updating records or...
Posted by bmains | with no comments
Filed under: ,
I don't know if anyone has come across this, but I ran into an interesting issue today. I had done this LINQ query in C#: from c in store.Customers where c.IsActive = true select c; What I was trying to accomplish is find all of the customers where...
Posted by bmains | with no comments
Filed under:
I had an issue using AsQueryable() in some of my code. What I was trying to do is this: CustomerDAL customers = new CustomerDAL(this.DataContext); short key1 = customers.GetPrimaryContact(selectedCustomer).CustomerKey; short key2 = customers.GetSecondaryContact...
Posted by bmains | with no comments
Filed under:
I found this a while ago about using dynamic LINQ in your code. This really works well with the ASP.NET GridView (and other data bound controls) where sorting is supported. Because, when a column header is clicked, the Sorting event fires with the details...
Posted by bmains | 2 comment(s)
Filed under:
LINQ to SQL is an intricate, yet "sensitive" tool into how it works. A LINQ to SQL query is translated into a SQL query that is performed against the database. This process occurs through a series of components that break the expression down...
Posted by bmains | with no comments
Filed under:
One of the problems you may experience is the issue of postbacks with the "staleness" of queried data. Because ASP.NET is stateless, when after unloading resources, all previously known resources are gone. A common way to keep data around is...
Posted by bmains | with no comments
Filed under: ,
I've mentioned before (probably several times) about using LINQ business object references instead of key (or other) values in your BAL or DAL code. Though I have mentioned it before, I decided to come up with a few scenarios. The first scenario is...
Posted by bmains | with no comments
Filed under:
More Posts Next page »