Re: Embedded SQL in C#
- From: "David Browne" <davidbaxterbrowne no potted meat@xxxxxxxxxxx>
- Date: Thu, 29 Dec 2005 14:34:24 -0600
"VictorReinhart" <victora.reinhart@xxxxxxx> wrote in message
news:1135886763.355587.61010@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi,
> I am intersted in trying to reduce the cost of C# development, by
> reducing the number of lines of code. In my opinion, as a business
> developer, the biggest opportunity to reduce the number of lines of
> code is in database access.
>
> My reality is that I use relational databases a lot. Other constructs,
> such as flat files, Web Services, arrays, etc I don't use very much.
>
> My data is stored on relational databases. I think that's pretty
> common, nowadays.
>
> I have been using ADO.NET and was wondering about the future.
>
> Will C# support truly embedded SQL in the future? For example, in
> PowerBuilder, since 1992, you could code as follows:
>
Static Embedded SQL: No. DataSets and TableAdapters, or Code Generators or
ORM frameworks give you most of the benefits of embedded SQL without having
to have something official in the languages or framework.
For the future, a whole set of query constructs are being added to the .NET
languages which will allow simple and elegant expression of queries in .NET
laguages against relational, XML and object data sources. This project is
called LINQ:
http://msdn.microsoft.com/netframework/future/linq/default.aspx
A simple query against a relational source will look something like:
// establish a query context over ADO.NET sql connection
DataContext context = new DataContext(
"Initial Catalog=petdb;Integrated Security=sspi");
// grab variables that represent the remote tables that
// correspond to the Person and Order CLR types
Table<Person> custs = context.GetTable<Person>();
Table<Order> orders = context.GetTable<Order>();
// build the query
var query = from c in custs, o in orders
where o.Customer == c.Name
select new {
c.Name,
o.OrderID,
o.Amount,
c.Age
};
// execute the query
foreach (var item in query)
Console.WriteLine("{0} {1} {2} {3}",
item.Name, item.OrderID,
item.Amount, item.Age);
David
.
- Follow-Ups:
- Re: Embedded SQL in C#
- From: VictorReinhart
- Re: Embedded SQL in C#
- References:
- Embedded SQL in C#
- From: VictorReinhart
- Embedded SQL in C#
- Prev by Date: Re: Please help with converting a Date and a Time string after con
- Next by Date: Re: Close connection problem
- Previous by thread: Re: Embedded SQL in C#
- Next by thread: Re: Embedded SQL in C#
- Index(es):
Relevant Pages
|