I just started to get acquainted with the LINQ technology, specifically DLINQ. It should probably be renamed DIMES (D*** It, Make Everything SQL).
It is definitely going to take some getting used to, but it is a cool concept.
In listing 1, I load a Typed DataSet for the Microsoft Access FPNWIND database using two adapters: ProductsTableAdapter and CustomersTableAdapter. All of the adapter and typed dataset code was generated for me courtesy of Data->Add New Data Source.
My first DLINQ statement gets all the cities fron the Customers table and spits them out to the console.
Here is the link statements. First I constructed a query from a typed data row. Then I performed the LINQ Query and finally I just spit out the results of the query to the console:
Listing 1: Getting Data Into a Query and Using LINQ
var customerQuery = ds.Customers.ToQueryable<LINQConsoleApplication1.FPNWINDDataSet.CustomersRow>;
var query = from customer in customerQuery select customer.City;
Here is the full code for performing the list of cities to the console window:
using System;
using System.Collections.Generic;
using System.Text;
using System.Query;
using System.Xml.XLinq;
using System.Data.DLinq;
using System.Data;
using LINQConsoleApplication1.FPNWINDDataSetTableAdapters;
namespace LINQConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
FPNWINDDataSet ds = new FPNWINDDataSet();
FPNWINDDataSetTableAdapters.CustomersTableAdapter customerAdapter = new CustomersTableAdapter();



Mike GoldPosted Jun 22, 2007, 3:05 PM
I actually generated the connection string from the Server Explorer, so I had to look. It seems the connection string is generated in the appsettings file: LINQConsoleApplication1\Properties\Settings.Designer.cs(29): [global::System.Configuration.DefaultSettingValueAttribute("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\FPNWIND.MDB")] public string FPNWINDConnectionString { get { return ((string)(this["FPNWINDConnectionString"])); } } As well as the XSD which generates this code: <Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="FPNWINDConnectionString" ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly" Name="FPNWINDConnectionString (Settings)" PropertyReference="ApplicationSettings.LINQConsoleApplication1.Properties.Settings.GlobalReference.Default.FPNWINDConnectionString" Provider="System.Data.OleDb"> All the actual connecting to the database seems to be generated from the xsd and stored in the designer cs file.
Mahesh ChandPosted Jun 22, 2007, 11:18 AM
Mike, This actually could be an article ;). Is there any concept of database connection string? Where do you specify that? Can you send me the source code? Thanks, Mahesh