This example shows how to query a single table without creating a data context class. This example uses Basic Mapping which means that the class property names must match the table field names.

using System;
using System.Collections.Generic;
using System.Linq;
using LinqToVfp;

namespace LinqToVfpQuickStart {
    static class Program {
        [STAThread]
        static void Main() {
            string northwindDbcPath = "your path";
            string connectionString = string.Format("Provider=VFPOLEDB.1;Data Source={0};Exclusive=false;Ansi=true;", northwindDbcPath);

            using (VfpQueryProvider provider = VfpQueryProvider.Create(connectionString, null)) {
                List<Customer> customers = (from customer in provider.GetTable<Customer>("Customers")
                                            orderby customer.CompanyName
                                            select customer).ToList();
            }
        }
    }

    public class Customer {
        public string CustomerID { get; set; }
        public string CompanyName { get; set; }
    }
}

Last edited Apr 17, 2010 at 4:02 PM by TomBrothers, version 1

Comments

No comments yet.