|
Posted by Ed Murphy on 11/17/07 16:49
steve wrote:
> On Nov 16, 7:41 am, Tom van Stiphout <no.spam.tom7...@cox.net> wrote:
>> I agree with you, but isn't this a strike against LINQ?
Depends. If LINQ implicitly protects against injection, then it's
precisely the opposite.
> LINQ is to a database as asking a child to build a cyclotron. What you
> get is some well intentioned but mangled piece of work that bears
> little relation to reality. What a gigantic waste of resources. Had
> they only brought in people who new even the basic ideas of a 'real
> relational database' MS might well be on the way to breaking new
> ground in an area dormat forever. Now they simply have something they
> can say 'hides' sql from the net developer. It seems what was
> important was to design something, anything, so long as it would
> 'hide' sql. If anyone can explain what ideas/principles were being
> followed I'd love to hear from them. MS has a net group and a database
> group. Obviously they need another.
Let's have a look, then, shall we?
http://en.wikipedia.org/wiki/Language_Integrated_Query#LINQ_Code_Sample
----- begin quote -----
// the Northwind type is a subclass of DataContext created by SQLMetal
// Northwind.Orders is of type Table<Order>
// Northwind.Customers is of type Table<Customer>
Northwind db = new Northwind(connectionString);
// use 'var' keyword because there is no name for the resultant type of
the projection
var q = from o in db.Orders
from c in db.Customers
where o.Quality == "200" && (o.CustomerID == c.CustomerID)
select new { o.DueDate, c.CompanyName, c.ItemID, c.ItemName };
// q is now an IEnumerable<T>, where T is the anonymous type generated
by the compiler
foreach (var t in q)
{
// t is strongly typed, even if we can't name the type at design time
Console.WriteLine("DueDate Type = {0}", t.DueDate.GetType());
Console.WriteLine("CompanyName (lowercased) = {0}",
t.CompanyName.ToLower());
Console.WriteLine("ItemID * 2 = {0}", t.ItemID * 2);
}
----- end quote -----
Look at the comments, in particular. If the type /could/ be named at
design time, at both the database and application layer, then would
your Holy Grail have finally been achieved?
Navigation:
[Reply to this message]
|