about 1 year ago - 2 comments
.Net 3.5 had some nice tricks in it. LINQ-to-XML was one of them. With the new "X"-types, you can make working with XML really easy.
VB.Net 9 takes it one step further, and lets you write XML in your code without strings.
"Hey Rich, that’s old news," I hear you say. "And who’s interested in VB [...]
about 1 year ago - No comments
Have you wondered if and when you should use the new LINQ features in .Net 3.5?
Like, where should I put a new extension method? Should I use Func<T> or a custom delegate? How do I best implement a mix-in (extension methods on an interface)?
Well, Mircea Trofin has just published a new draft of some LINQ [...]
about 2 years ago - No comments
I just read a fantastic quote about LINQ from the book Pro LINQ: Language Integrated Query in C# 2008 by Joseph C. Rattz, Jr.:
I prefer to think of LINQ as a data iteration engine, but perhaps Microsoft didn’t want a technology named DIE.
I think they already built the technology for such a product, and [...]
about 2 years ago - 1 comment
I was recently reading Programming Ruby: The Pragmatic Programmers’ Guide, Second Edition, and came across this piece of example Ruby code:
[1,3,5,7].inject(0) {|sum, element| sum+element} -> 16 [1,3,5,7].inject(1) {|product, element| product*element} -> 105
Inject is a method which acts on an array by aggregating or accumulating the values within that array. It [...]
about 2 years ago - No comments
One of my favorite bloggers is Matt Berseth. Nearly once a week he comes up with a post where he does something amazing with the standard ASP.Net controls. I usually read his posts in awe. He’s really good.
But he’s not only is a good developer, he’s a great writer. Even though his posts are concise [...]
about 2 years ago - 2 comments
Yesterday I thought I’d learn about the LinqDataSource in ASP.Net 3.5, and got an interesting surprise.
The new LinqDataSource can also be used with a LINQ-to-SQL model to perform updates. You simply add the DataSource to your page, set the table name, and set EnableUpdate to true. Then, using a standard DataControl, you can make updates [...]
about 2 years ago - 25 comments
When learning LINQ-to-SQL, it’s not immediately obvious how to do an update. Querying is easy, and there are methods for inserting and deleting. Updating usually occurs by modifying an object already known to the DataContext and then calling SubmitChanges on the context.
var product = (from p in dataContext.Products
[...]
about 2 years ago - 2 comments
Until recently I thought this was a well-known feature. After demonstrating it a few times, I found out it wasn’t.
A long time ago, in an cubicle far, far away, someone created the .Net Framework. To cut a long story short, they simultaneously produced guidelines for creating Exception classes, which you should always use or face [...]
about 2 years ago - 9 comments
When you started using LINQ, did you think it looked like SQL? I did.
The more I learned LINQ, the more I realized it wasn’t anything like SQL. Take grouping, for example. Because LINQ has a group by statement, and it looks like SQL, I assumed that the syntax for grouping in LINQ would be just [...]
about 2 years ago - 3 comments
Last week I had to prepare a small presentation for a new LINQ workshop. For my research, I browsed through the MSDN documentation on LINQ where I came across a reference to "LINQ to DataSets". I couldn’t find any more information about it though, and so LINQ to DataSets got a small mention in my [...]