예제 #1
0
 public IQueryable <Customer> GetAllCustomers()
 {
     using (NWDbContext dbContext = new NWDbContext())
     {
         return(dbContext.Customers);
     }
 }
예제 #2
0
 public Customer GetCustomerUsingMethodSyntax(int id)
 {
     using (NWDbContext dbContext = new NWDbContext())
     {
         return(dbContext.Customers.Where(c => c.CustomerID == id).First());
     }
 }
예제 #3
0
 public Customer GetCustomerUsingMethodSyntaxAndAssignToVariable(int id)
 {
     using (NWDbContext dbContext = new NWDbContext())
     {
         var query = dbContext.Customers.Where(c => c.CustomerID == id).First();
         return(query);
     }
 }
예제 #4
0
 public Customer GetCustomerUsingMethodSyntaxAndQueryIsChangedInMultipleLines(int id)
 {
     using (NWDbContext dbContext = new NWDbContext())
     {
         var query = dbContext.Customers.AsQueryable();
         query = query.Where(c => c.CustomerID == id);
         return(query.First());
     }
 }
예제 #5
0
 public Customer GetCustomerUsingQuerySyntax(int id)
 {
     using (NWDbContext dbContext = new NWDbContext())
     {
         return((from c in dbContext.Customers
                 where c.CustomerID == id
                 select c).First());
     }
 }
예제 #6
0
 public Customer GetCustomerUsingQuerySyntaxAndAssignToVariable(int id)
 {
     using (NWDbContext dbContext = new NWDbContext())
     {
         var query = (from c in dbContext.Customers
                      where c.CustomerID == id
                      select c);
         return(query.First());
     }
 }