/// <summary> /// Get customer details without orders /// </summary> /// <param name="context"></param> /// <returns></returns> public static IQueryable <Customer> PartialCompleteCustomers(this NorthWindAzureContext context) { return(context.Customers .Include(customer => customer.Country) .Include(customer => customer.Contact) .Include(customer => customer.ContactType)); }
public async Task <List <CustomerEntity> > AllCustomersAsync(NorthWindAzureContext context) { _context = context; var customerData = await( from customer in context.Customers join contactType in context.ContactTypes on customer.ContactTypeIdentifier equals contactType.ContactTypeIdentifier join contact in context.Contacts on customer.ContactId equals contact.ContactId select new CustomerEntity { CustomerIdentifier = customer.CustomerIdentifier, CompanyName = customer.CompanyName, ContactIdentifier = customer.ContactId, FirstName = contact.FirstName, LastName = contact.LastName, ContactTypeIdentifier = contactType.ContactTypeIdentifier, ContactTitle = contactType.ContactTitle, Address = customer.Address, City = customer.City, PostalCode = customer.PostalCode, CountryIdentifier = customer.CountryIdentifier, CountyName = customer.Country.Name }).Take(10).ToListAsync(); return(customerData); }
private void Form1_Shown(object sender, EventArgs e) { using (var context = new NorthWindAzureContext()) { var customers = context.Customers.Select(cust => new CustomerSpecial { Id = cust.CustomerIdentifier, CompanyName = cust.CompanyName, ContactName = cust.ContactName, Country = cust.Country.CountryName }).ToList(); view = new BindingListView <Customer>(customers); context.Customers.Load(); var demo = context.Customers.Local.ToBindingList(); var testcust = demo.FirstOrDefault(cust => cust.CustomerIdentifier == 3); testcust.CompanyName = "SSSSSSSS"; Console.WriteLine(); dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = view; //var likeResult = context.Customers.Where(c => DbFunctions.Like(c.City, "%on")).ToList(); //Console.WriteLine(); //likeResult = context.Customers.Where(c => DbFunctions.Like(c.City, "M%")).ToList(); //Console.WriteLine(); } }
/// <summary> /// Get all contact types /// </summary> /// <returns></returns> public List <ContactType> GetContactTypes() { using (var context = new NorthWindAzureContext()) { context.Configuration.LazyLoadingEnabled = false; return(context.ContactTypes.ToList()); } }
/// <summary> /// Get all known contacts /// </summary> /// <returns></returns> public List <Contact> GetContacts() { using (var context = new NorthWindAzureContext()) { // indicates not to load Customers context.Configuration.LazyLoadingEnabled = false; return(context.Contacts.ToList()); } }
public static Customer CustomerById1(this NorthWindAzureContext context, int customerIdentifier) { return(context.Customers .Include(customer => customer.Country) .Include(customer => customer.Contact) .Include(customer => customer.ContactType) .Include(customer => customer.Orders.Select(ord => ord.Order_Details)) .FirstOrDefault(cust => cust.CustomerIdentifier == customerIdentifier)); }
/// <summary> /// Get single customer by customer identifier and return customer data and order data /// excluding complete order details. /// </summary> /// <param name="context"></param> /// <param name="customerIdentifier"></param> /// <returns></returns> public static Customer CustomerById(this NorthWindAzureContext context, int customerIdentifier) { return(context.Customers .Include(customer => customer.Country) .Include(customer => customer.Contact) .Include(customer => customer.ContactType) .Include(customer => customer.Orders) .FirstOrDefault(c => c.CustomerIdentifier == customerIdentifier)); }
/// <summary> /// Get all countries /// </summary> /// <returns></returns> public List <CountryItem> GetCountries() { using (var context = new NorthWindAzureContext()) { // indicates not to load Customers context.Configuration.LazyLoadingEnabled = false; return(context.Countries.Select(country => new CountryItem() { CountryIdentifier = country.CountryIdentifier, CountyName = country.Name }).ToList()); } }
public void Casing() { using (var context = new NorthWindAzureContext()) { context.Configuration.LazyLoadingEnabled = false; var example = context.Customers .Include(cust => cust.Country) .Include(cust => cust.Contact) .ToList(); foreach (var customer in example) { customer.Country.Customers = null; } } }
public List <ProductCheckedListBox> ProductsByCategories(List <int?> identifiers) { using (var context = new NorthWindAzureContext()) { return(context.Products .Include(product => product.Category) .WithIdentifiers(product => product.CategoryID, identifiers) .Select(product => new ProductCheckedListBox() { ProductID = product.ProductID, ProductName = product.ProductName, CategoryName = product.Category.CategoryName }) .ToList()); } }
/// <summary> /// Return customers by country using country identifier(s) /// </summary> /// <param name="identifiers">one or more country identifiers</param> /// <returns></returns> public List <CustomerCountries> CustomersByCountries(List <int?> identifiers) { using (var context = new NorthWindAzureContext()) { return(context.Customers .Include(customer => customer.Contact) .Include(customer => customer.Country) .WithIdentifiers(customer => customer.CountryIdentifier, identifiers) .Select(customer => new CustomerCountries() { CustomerIdentifier = customer.CustomerIdentifier, CompanyName = customer.CompanyName, FirstName = customer.Contact.FirstName, LastName = customer.Contact.LastName, CountryName = customer.Country.Name }).ToList()); } }