Showing posts with label linq. Show all posts
Showing posts with label linq. Show all posts
Monday, September 06, 2010
LINQ2SQL Transaction
A good thread to read on LINQ to SQL transactions, centred on commits and rollbacks:
Friday, August 13, 2010
LINQ2SQL Exception: The query contains references to items defined on a different data context
When getting the exception
The query contains references to items defined on a different data context.Check that the context object being used for each 'from' and 'join', etc, within LINQ statements is not a new object but the same one being re-used!
Wednesday, August 11, 2010
LINQ: NOT IN / NOT EXISTS
So, while trying to get a fairly straight forward (I thought) select ... from ... where ... not in (...) I found that there is not really an equivalent in LINQ, or so I thought...
Read the solution here:
- http://programminglinq.com/blogs/marcorusso/archive/2008/01/14/the-not-in-clause-in-linq-to-sql.aspx
A quick sample from me:
var orphans = (from c in context.Instances
orderby c.Title
where !(from o in context.CategoryInstances
select o.InstanceID)
.Contains(c.InstanceID)
select c).Skip(PageIndex * PageSize).Take(PageSize);
Essentially, the query does the same thing in C# - that is, to get the list of IDs to check within and then check within it for the ID which is hoping to be not found. Because the whole thing is compiled into SQL before before executed, LINQ generates a NOT EXISTS statement in the WHERE clause, rather than the slower NOT IN.
Friday, June 18, 2010
Calculate XML Element Depth
In XPath (from the excellent D.Pawson site):
select="count(ancestor::*)"
- http://www.dpawson.co.uk/xsl/sect2/N2193.html
In LINQ:
- int depth = element.Ancestors().Count();
Monday, January 25, 2010
LINQ, LINQ2SQL, LINQ2XML. It's linky...
Boning up on LINQ and I'm finding bits all over the place. So, another personal haven of links and hopefully useful info now resides on this post...
Sunday, March 15, 2009
Microsoft links I have yet to read, but really should...
How Do I: Create a Breakpoint
Using Conditions?
How Do I: Create a Breakpoint Using Hit Count?
How Do I; Learn Tips and Tricks for Debugging in Visual Studio?
Office Development with Visual Studio Developer
Center Just Launched!
Microsoft Cloud Computing Tools
How Do I: Add Tool Windows to the Visual Studio IDE?
How Do I: Add a New Tool Window to Visual Studio?
How Do I: Integrate With the Error List?
How Do I: Create a Basic Language Service Using the Managed Babel System?
How Do I: Create Custom
Project Templates Using Visual Studio 2008?
How Do I: Create an Item Template Using Visual Studio 2008?
How Do I: Write to the Output Window?
Explore the New Features of Visual Studio 2008
How Do I: Create a Debugger Visualizer?
How Do I: Place My Commands Into Different Kinds of Visual Studio Menus?
How Do I: Add Commands
and Controls Into the Visual Studio IDE?
How Do I: Get Started with the VisualStudio Domain Specific Languages?
Heroes Happen Here
DotNetNuke® and Visual Studio 2008
Visual Studio Tip of the Day
How Do I: Add AJAX Functionality to an Existing ASP.NET Page?
How Do I: Debug a Windows Presentation Foundation Application in Visual Studio 2008?
How Do I: Use the LINQ-Enabled
XML API in Visual Studio 2008?
Using Conditions?
How Do I: Create a Breakpoint Using Hit Count?
How Do I; Learn Tips and Tricks for Debugging in Visual Studio?
Office Development with Visual Studio Developer
Center Just Launched!
Microsoft Cloud Computing Tools
How Do I: Add Tool Windows to the Visual Studio IDE?
How Do I: Add a New Tool Window to Visual Studio?
How Do I: Integrate With the Error List?
How Do I: Create a Basic Language Service Using the Managed Babel System?
How Do I: Create Custom
Project Templates Using Visual Studio 2008?
How Do I: Create an Item Template Using Visual Studio 2008?
How Do I: Write to the Output Window?
Explore the New Features of Visual Studio 2008
How Do I: Create a Debugger Visualizer?
How Do I: Place My Commands Into Different Kinds of Visual Studio Menus?
How Do I: Add Commands
and Controls Into the Visual Studio IDE?
How Do I: Get Started with the VisualStudio Domain Specific Languages?
Heroes Happen Here
DotNetNuke® and Visual Studio 2008
Visual Studio Tip of the Day
How Do I: Add AJAX Functionality to an Existing ASP.NET Page?
How Do I: Debug a Windows Presentation Foundation Application in Visual Studio 2008?
How Do I: Use the LINQ-Enabled
XML API in Visual Studio 2008?
Subscribe to:
Posts (Atom)