Re: Embedded SQL in C#

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"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


.



Relevant Pages

  • Re: Table of cells contains comingled text (A,B,C,1,2,3)-formated
    ... > Delimiter As String) As Long ... > Dim Items As Variant ... Each of these fields will look like this in the query ...
    (microsoft.public.access.gettingstarted)
  • Re: Option groups, passing a string value to table
    ... but that is the recommended approach with Relational databases. ... having the words there doesn't improve maintenance: ... query and use the query rather than the table (seldom, if ever, should you ... "Scott" wrote in message ...
    (microsoft.public.access.forms)
  • Re: Queries and OO
    ... Queries is a way to decouple how objects are mapped into a container, ... long time ago there were database types without query ... But maybe the query capabilities was one of the reasons behind the ... success story of relational databases. ...
    (comp.object)
  • Re: Create a sorted table (DAO)
    ... If you must have the data sorted, you have no choice but to use a query. ... There's no such thing as a "sorted table" in relational databases. ... "Stefanie" wrote in message ... stores data to this table. ...
    (microsoft.public.vb.database)
  • Re: Opening table - query running?
    ... Relational databases are NOT flat files. ... and running a query. ... open a recordset that returns the entire table. ...
    (microsoft.public.access.tablesdbdesign)