# Wednesday, August 19, 2009

The following example is a quick proof of concept simply showing how to view the Customer table from the Northwind.dbc.

  1. Create a new WebSite.
  2. Add references to IQToolkit.dll and LinqToVfp.dll
  3. Add a Northwind connection string setting to the web.config
    <connectionStrings>
        <add name="northwind" 
             providerName="System.Data.OleDb" 
             connectionString="Provider=VFPOLEDB.1;Data Source=**Your Path**\Northwind.dbc;"/>
    </connectionStrings>
  4. Add a new class:  Customer.cs
    public class Customer {
        public string CustomerId { get; set; }
        public string CompanyName { get; set; }
        public string ContactName { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public string Region { get; set; }
        public string PostalCode { get; set; }
        public string Country { get; set; }
        public string Phone { get; set; }
        public string Fax { get; set; }
    }
  5. Add a new class:  Northwind.cs
    using System.Configuration;
    using IQToolkit;
    using LinqToVfp;
     
    public class Northwind : AVfpDatabaseContainer {
        public Northwind()
            : base(ConfigurationManager.ConnectionStrings["northwind"].ConnectionString, null) {
     
            // this will make it so that all command will be logged to the Output windoww
            this.Provider.Log = VfpQueryProvider.CreateDebuggerWriter();
        }
     
        public IEntityTable<Customer> Customers {
            get { return this.Provider.GetTable<Customer>("Customers"); }
        }
    }
  6. Modify Default.aspx to include to following in the div tag:
    <asp:GridView ID="mainGrid" 
                  runat="server" 
                  DataSourceID="LinqDataSource1" 
                  AllowPaging="True"
                  AllowSorting="True" />
     
    <asp:LinqDataSource ID="LinqDataSource1" 
                        runat="server" 
                        ContextTypeName="Northwind"  
                        TableName="Customers" />
8/19/2009 7:07 AM Eastern Daylight Time  #    Disclaimer  |  Comments [0]  |