Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 1st, 2012  |  syntax: None  |  size: 0.40 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Auto generate class properties by binding to database lookup table
  2. string countryCode = Country.Egypt.Code
  3.        
  4. using (var db = new DataClasses1DataContext()) {
  5.     COUNRTY egypt = db.COUNRTies.Where(row => row.NAME == "Egypt").SingleOrDefault();
  6.     if (egypt == null) {
  7.         // "Egypt" is not in the database.
  8.     }
  9.     else {
  10.         var egypt_code = egypt.CODE;
  11.         // Use egypt_code...
  12.     }
  13. }