code_junkie

a newbie question on Linq To Sql

Nov 12th, 2011
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. public class AdventureWorks : DataContext
  2. {
  3. public AdventureWorks(string connection) : base(connection) { }
  4. public Table<Contact> Contacts;
  5. }
  6.  
  7. [Table(Name = "Person.Contact")]
  8. public class Contact
  9. {
  10.  
  11. [Column(DbType = "int not null", IsPrimaryKey = true, IsDbGenerated = true)]
  12. public int ContactID;
  13.  
  14. [Column(DbType = "nvarchar(8) not null")]
  15. public string Title;
  16.  
  17. [Column(DbType = "nvarchar(50) not null")]
  18. public string FirstName;
  19.  
  20. [Column(DbType = "nvarchar(50) not null")]
  21. public string MiddleName;
  22.  
  23. [Column(DbType = "nvarchar(50) not null")]
  24. public string LastName;
  25.  
  26. [Column(DbType = "nvarchar(50) not null")]
  27. public string EmailAddress;
  28.  
  29. [Column(DbType = "int")]
  30. public int EmailPromotion;
  31.  
  32. [Column(DbType = "bit")]
  33. public byte NameStyle;
  34.  
  35. [Column(DbType = "varchar(40)")]
  36. public string PasswordHash;
  37.  
  38. [Column(DbType = "varchar(40)")]
  39. public string PasswordSalt;
  40.  
  41. }
  42.  
  43. AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
  44. Contact cont = db.Contacts.Single(c => c.ContactID == 1280);
  45.  
  46. using System.Data.Linq;
  47. using System.Linq;
Add Comment
Please, Sign In to add comment