コード例 #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());
     }
 }