By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,761 Members | 1,193 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,761 IT Pros & Developers. It's quick & easy.

LINQ and SQL in general.

P: n/a
Hello all,

I learn about LINQ here in this forum. I been a VB.NET programmer for
quite a while and we are using an internal solution for SQL access. I
have some experience with C# and I started to write a blog to share my
experiences with a sql framework.
I would like to hear some opinions about LINQ, is it the main thing
when accessing sql now? what are the main advantages/disavantages
using it. Nothing fancy, just drop a few lines about it...
I read some material but I want to hear the opinion from the field.
I'll be glad to share experience in this area.

Thanks in advance.

Alcides (http://alsql.blogspot.com/).

Feb 27 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
LINQ is most useful, to me, for easily iterating through objects that use
IEnumerable. This includes sql constructs created by using LINQ to SQL
queries, but it is equally useful, if not more so, for generically querying
sets of objects, etc.

LINQ itself is good for the average web scenario, but can fall flat on high
performance, high load applications. Anything where you have to grab large
amounts of data before a save is not best done with LINQ, for example.

Overall, if you do not think of LINQ as data access, it is a good thing.
When you start thinking of it as a transport "layer", you can end up making
some bad decisions.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
"Alcides" <al************@hotmail.comwrote in message
news:4c**********************************@41g2000h sc.googlegroups.com...
Hello all,

I learn about LINQ here in this forum. I been a VB.NET programmer for
quite a while and we are using an internal solution for SQL access. I
have some experience with C# and I started to write a blog to share my
experiences with a sql framework.
I would like to hear some opinions about LINQ, is it the main thing
when accessing sql now? what are the main advantages/disavantages
using it. Nothing fancy, just drop a few lines about it...
I read some material but I want to hear the opinion from the field.
I'll be glad to share experience in this area.

Thanks in advance.

Alcides (http://alsql.blogspot.com/).

Feb 27 '08 #2

P: n/a
The main advantage I see is that it can simplify the interfacing between a
database (hierarchy model) and the code (object model).

The big disadvantage is that it is much more complex than SQL to define JOIN
or complex expressions, as when many tables are involved. So, LINQ would
probably be limited to 'query' involving very few tables, or to
view/function stored into the database where the complexity is pre-defined
using SQL.
Vanderghast, Access MVP
"Alcides" <al************@hotmail.comwrote in message
news:4c**********************************@41g2000h sc.googlegroups.com...
Hello all,

I learn about LINQ here in this forum. I been a VB.NET programmer for
quite a while and we are using an internal solution for SQL access. I
have some experience with C# and I started to write a blog to share my
experiences with a sql framework.
I would like to hear some opinions about LINQ, is it the main thing
when accessing sql now? what are the main advantages/disavantages
using it. Nothing fancy, just drop a few lines about it...
I read some material but I want to hear the opinion from the field.
I'll be glad to share experience in this area.

Thanks in advance.

Alcides (http://alsql.blogspot.com/).
Feb 27 '08 #3

P: n/a
"Michel Walsh" <va*************************@nospam.comwrites:
The main advantage I see is that it can simplify the interfacing
between a database (hierarchy model) and the code (object model).
Hierachical databases are from the 70ties and in many use cases do
have much more disadvantages than advantages. Todays DBMS like MS SQL,
Oracle, PostgreSQL etc. are some kind of misguided relational systems
(SQL in many many cases contradicts the relational model and tears
quite some holes in it). BTW XML is a hierachical model (so quite
70ties, not very modern :)).

--
Stefan.
Feb 27 '08 #4

P: n/a
Michel Walsh wrote:
The main advantage I see is that it can simplify the interfacing
between a database (hierarchy model) and the code (object model).
You ment 'relational model' ? There's nothing hierarchical about a
relational model.
The big disadvantage is that it is much more complex than SQL to
define JOIN or complex expressions, as when many tables are involved.
not necessarily. Perhaps left joins, but joins in general are pretty
straight forward (as in, same keywords as SQL)
So, LINQ would probably be limited to 'query' involving very few
tables, or to view/function stored into the database where the
complexity is pre-defined using SQL.
Can you show an example where the SQL query is simpler than the Linq
query?

FB
>

Vanderghast, Access MVP
"Alcides" <al************@hotmail.comwrote in message
news:4c**********************************@41g2000h sc.googlegroups.com.
..
Hello all,

I learn about LINQ here in this forum. I been a VB.NET programmer
for quite a while and we are using an internal solution for SQL
access. I have some experience with C# and I started to write a
blog to share my experiences with a sql framework.
I would like to hear some opinions about LINQ, is it the main thing
when accessing sql now? what are the main advantages/disavantages
using it. Nothing fancy, just drop a few lines about it...
I read some material but I want to hear the opinion from the field.
I'll be glad to share experience in this area.

Thanks in advance.

Alcides (http://alsql.blogspot.com/).


--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Feb 28 '08 #5

P: n/a
You are right, I meant relational !

An example? sure. Either a group by with conditions (note the b.kindOf can
be re-written as a WHERE clause, here)

SELECT a.myGroup, SUM(b.myValue)
FROM myTable AS a INNER JOIN myReference AS b
ON a.someID = b.refID AND b.kindOf= 1
GROUP BY a.myGroup
HAVING MIN(b.myValue) >0;
either a ranking (non-equi join)

SELECT a.state, COUNT(*) AS rank
FROM myTable AS a INNER JOIN myTable AS b
ON a.population <= b.population
GROUP BY a.state

which rank each state in accordance with their population.

Even a simple translation:

SELECT a.cityName, COALESCE(b.cityname, a.cityName)
FROM cities AS a LEFT JOIN translations AS b
ON a.cityID=b.cityID
such as 'Byzance' and 'Constantinople' are translated as 'Istanbul, but
'Brasilia, having no match in table translations, stays 'Brasilia. Thanks
thanks to COALESCE, it would be arguably as simple as SQL, in LINQ.
These queries are not elementary, sure, but they do not involve correlated
sub-query either, and only 2 tables.

Vanderghast, Access MVP
"Frans Bouma [C# MVP]" <pe******************@xs4all.nlwrote in message
news:xn***************@news.microsoft.com...
Michel Walsh wrote:
>The main advantage I see is that it can simplify the interfacing
between a database (hierarchy model) and the code (object model).

You ment 'relational model' ? There's nothing hierarchical about a
relational model.
>The big disadvantage is that it is much more complex than SQL to
define JOIN or complex expressions, as when many tables are involved.

not necessarily. Perhaps left joins, but joins in general are pretty
straight forward (as in, same keywords as SQL)
>So, LINQ would probably be limited to 'query' involving very few
tables, or to view/function stored into the database where the
complexity is pre-defined using SQL.

Can you show an example where the SQL query is simpler than the Linq
query?

FB
>>

Vanderghast, Access MVP
"Alcides" <al************@hotmail.comwrote in message
news:4c**********************************@41g2000 hsc.googlegroups.com.
..
Hello all,

I learn about LINQ here in this forum. I been a VB.NET programmer
for quite a while and we are using an internal solution for SQL
access. I have some experience with C# and I started to write a
blog to share my experiences with a sql framework.
I would like to hear some opinions about LINQ, is it the main thing
when accessing sql now? what are the main advantages/disavantages
using it. Nothing fancy, just drop a few lines about it...
I read some material but I want to hear the opinion from the field.
I'll be glad to share experience in this area.

Thanks in advance.

Alcides (http://alsql.blogspot.com/).

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Feb 28 '08 #6

P: n/a
>
>By the way, another great advantage to LINQ: it allows you to write a
query
against a database where, in theory, you can be forbidden to write any
query
(by some administrative politic).

Not sure what you mean by that, to be honest.

I mixed two concepts. Once you got the data, locally, you can probably
use LINQ to objects to query the objects, without using the database at all,
without using LINQ to database, in case the admin do not allow your access
to run (write) ad hoc query, on the database (even if they are not action
query).

Vanderghast, Access MVP

Feb 28 '08 #7

P: n/a
On Feb 28, 3:19 pm, "Michel Walsh"
<vanderghastArobaseMsnDot...@nospam.comwrote:
By the way, another great advantage to LINQ: it allows you to write a
query
against a database where, in theory, you can be forbidden to write any
query
(by some administrative politic).
Not sure what you mean by that, to be honest.

I mixed two concepts. Once you got the data, locally, you can probably
use LINQ to objects to query the objects, without using the database at all,
without using LINQ to database, in case the admin do not allow your access
to run (write) ad hoc query, on the database (even if they are not action
query).
Ah, right. Yes, that's certainly possible - while somewhat inefficient
compared with doing it in the database, of course :)

Jon
Feb 28 '08 #8

P: n/a
Interesting discussion, it seems linq syntax can get very complex,
naturaly due to complexity of the sql query you are building. If your
application have a lot of complex queries, all the time, may not be
the appropiate solution, I wonder what would be?

But looks like linq can be handle most requests for a standard
aplication, I mean, leaving complex queries to the reports team (using
crystal reports, views and store procedures). Am I right?
Feb 28 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.