Eric Wise

Sponsors

The Lounge

Blogs I Read

Fun & Games

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Sahil on C# 3.0 and Linq

Sahil is off to the races in his new blog.  You should check out his series on C# 3.0 and linq features.

http://blah.winsmarts.com/2006/05/17/demystifying-c-30--part-1-implicitly-typed-local-variables-var.aspx

Personally, I'm a bit torn over the Linq thing.  It looks really neat on the surface, but I am struggling to figure out how this is really better than using stored procedures etc to return your data.  Maybe it's because as a web guy I'm used to working in a stateless environment so my data doesn't normally hang around long enough that Linq would be useful.


Posted 05-22-2006 1:34 PM by Eric Wise

[Advertisement]

Comments

Sahil Malik wrote re: Sahil on C# 3.0 and Linq
on 05-22-2006 1:49 PM
WALLA !! Yeah that series is taking off, I'm on #6 now -

http://blah.winsmarts.com/2006/05/21/demystifying-c-30--part-6-linq-query-expression-translation-to-c-30.aspx

The idea being, 5 minutes a day, read one blogpost, and climb a not so steep plank to .NET 3.0.

Now I feel you will be using it all over the place. This is not about web or windows - it's about how we program and deal with data. If you thought generics were big, generics are a little worm compared to this Hummer H1.

I think this will result in the grand-daddy of many design patterns we see today. LINQ is good.
Don Demsak wrote re: Sahil on C# 3.0 and Linq
on 05-22-2006 7:29 PM
Eric,

Don't confuse DLinq with Linq.  DLinq is an Object Relational Mapper implementation that makes use of Linq.  XLinq is a brand new XML object model built on top of Linq.  Linq may be the underpinnings of DLinq and XLinq, but any API developer can make use of Linq for their object model.  Or, if you only need the base Select functionality, you don't have to do anthing to your .Net collections to use Linq.  That is the beauty of Linq, it works over any .Net collection.
Sahil Malik wrote re: Sahil on C# 3.0 and Linq
on 05-23-2006 10:05 AM
And who is confusing DLINQ with LINQ?
Sahil Malik - blah.winsmarts.com wrote Demystifying C# 3.0 - Part 7: Expression Trees
on 05-23-2006 11:51 AM
In this series of Demystifying C# 3.0 we have already covered -   a) Demystifying C# 3.0 - Part 1: Implicitly Typed Local Variables "var"b) Demystifying C# 3.0 - Part 2: Anonymous Typesc) Demystifying C# 3.0 - Part 3: Extension Methodsd) Demystifying
Don Demsak wrote re: Sahil on C# 3.0 and Linq
on 05-23-2006 12:53 PM
Sahil - I think Eric is confusing DLinq with Linq with this statement "Personally, I'm a bit torn over the Linq thing.   It looks really neat on the surface, but I am struggling to figure out how this is really better than using stored procedures etc to return your data."

Linq has nothing to do with if you use stored procs versus code gen'd SQL.  That is all DLinq related.
Sahil Malik wrote re: Sahil on C# 3.0 and Linq
on 05-23-2006 2:42 PM
Ahh .. I see now. Thanks Don.
Jeffrey Palermo wrote re: Sahil on C# 3.0 and Linq
on 05-23-2006 3:42 PM
I do like being able to query objects.  Currently, one might put objects in a hashtable with the key being the item to be searched.  That allowed fast searching based on one criteria, but Linq will allow searching based on multiple criteria.

If it cuts down on development time without sacrificing maintainability, then it's a good thing.
Sahil Malik wrote re: Sahil on C# 3.0 and Linq
on 05-23-2006 4:17 PM
I have an article coming up - should be online this coming Monday which starts with discussing the pros and cons of the current architecture, and how LINQ helps out.

IMO - LINQ is good - there is absolutely no questioning that.

Regards DLINQ/ADO.NET 3.0 EDM, I am encouraged to see the considerable progress they have made in the May CTP. Lets see where that goes.
Eric Wise wrote re: Sahil on C# 3.0 and Linq
on 05-23-2006 7:57 PM
What I was really trying to voice was the following example:

I have an ASP .NET page that queries customer records.  There is a search filter at the top of the page, and a dataview that is pageable/sortable.

In the current world, I'm probably going to opt for some kind of dynamic query to toss back a datatable that is really easy to bind and automagically handles paging/sorting.  If I'm doing the paging myself I'm likely doing it in a stored procedure.

As soon as the page posts, this data is gone unless I store it in memory somewhere which isn't scalable at all.  At this point if the user changes the filter or requests a sort you're likely going back to the database...

1. Isn't sorting/filtering what the database does best?  Could the performance of DLinq over a large set of data possibly touch a database server?

2. Wouldn't most of your scenarios require persistance of some sort?  This is where I ponder whether it might be most useful in static, lookups of smaller sets of strongly typed objects.

Naturally this is all from a pure asp.net view.  On the client where you actually have access to robust local machine resources and persistance this isn't as much of a concern.
Sam Smoot wrote re: Sahil on C# 3.0 and Linq
on 05-23-2006 10:29 PM
Eric:

I think the utility may be non-obvious at first, but once we have them in .NET3, we'll wonder how we ever lived without them. Yes, for performance if nothing else, we want to filter in the database, but when you can do something like:

seniors, others = customers.partition { |customer| customer.age > 65 }

In memory, so you can group, massage, and butcher the data in convenient ways, it really helps out.

I really think this will probably be done better through extension methods however. I could overwrite Ruby's Array#find to look like an ActiveRecord::find, but why? The Array#find is more succinct, and even if it weren't, it would probably just be Too Much Magic. Extension Methods and Anonymous Methods together will make for a pretty wicked combination though methinks.
on 05-29-2009 10:29 PM

Buy amoxicillin without prescription. Amoxicillin. Amoxicillin dosage. Amoxicillin and clavulanate potassium. What is amoxicillin used for. Amoxicillin and strep b.