using System;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
[Table(Name="Sales.Customer")]
public class Customer
{
[Column] public string FirstName { get; set; }
[Column] public string LastName { get; set; }
[Column] public string EmailAddress { get; set; }
public override string ToString()
{
return string.Format("{0} {1}\nEmail: {2}",FirstName, LastName, EmailAddress);
}
}
public class Tester
{
static void Main()
{
DataContext db = new DataContext(@"Data Source=.\SqlExpress;Initial Catalog=AdventureWorks;Integrated Security=True");
Table<Customer> customers = db.GetTable<Customer>();
var query = from customer in customers where customer.FirstName == "D" select customer;
foreach(var c in query)
Console.WriteLine(c.ToString());
}
}
|