private void button1_Click(object sender, EventArgs e) { var repository = new SDataEntityRepository(SDATA_CONTRACT_URL, SDATA_USERNAME, SDATA_PASSWORD); IQueryable <IContact> query = from contact in repository.CreateQuery <IContact>() where contact.FirstName == txtFirstNameSearch.Text //&& contact.YearGraduated > 1960 select contact; _contactList = query.ToList(); if (_contactList.Count == 0) { Text = "No matching entities found"; } //var accountList = (from account in repository.CreateQuery<IAccount>() // where account.Employees > 200 // select account).ToList(); ////Projecting anonymous type //var miniContacts = from contact in repository.CreateQuery<IContact>() // where contact.FirstName == txtFirstNameSearch.Text // select new { FN = contact.FirstName, LN = contact.LastName }; //var miniList1 = miniContacts.ToList(); ////query using extension methods //miniContacts = repository.CreateQuery<IContact>() // .Where(contact2 => contact2.FirstName == txtFirstNameSearch.Text) // .Select(contact2 => new { FN = contact2.FirstName, LN = contact2.LastName }); //var miniList2 = miniContacts.ToList(); ////project anonymous type with string concatenation //var contactNames = (from contact3 in repository.CreateQuery<IContact>() // select new { FullName = contact3.FirstName + " " + contact3.LastName }).ToList(); //var contactFullNameList = contactNames.ToList(); ////get by Id var contactById = repository.GetEntityById <IContact>("CA2EK0013122"); //lazy loaded relationship var accountName = contactById.Account.AccountName; var street = contactById.Account.Address.Address1; _contactIndex = 0; BindCurrentEntity(); }
private void btnTestCRUD_Click(object sender, EventArgs e) { const string address1 = "My Street"; var repository = new SDataEntityRepository(SDATA_CONTRACT_URL, SDATA_USERNAME, SDATA_PASSWORD); IAddress newAddress = repository.Create<IAddress>(); newAddress.Address1 = address1; newAddress.City = "Scottsdale"; newAddress.State = "Arizona"; newAddress.PostalCode = "85258"; newAddress.EntityId = "000000000000"; newAddress.Description = "This is a description"; repository.Save(newAddress); var addressQuery = from address in repository.CreateQuery<IAddress>() where address.Address1 == address1 select address; var getAddress = addressQuery.ToList().First(); repository.Delete(getAddress); }
private void btnTestCRUD_Click(object sender, EventArgs e) { const string address1 = "My Street"; var repository = new SDataEntityRepository(SDATA_CONTRACT_URL, SDATA_USERNAME, SDATA_PASSWORD); IAddress newAddress = repository.Create <IAddress>(); newAddress.Address1 = address1; newAddress.City = "Scottsdale"; newAddress.State = "Arizona"; newAddress.PostalCode = "85258"; newAddress.EntityId = "000000000000"; newAddress.Description = "This is a description"; repository.Save(newAddress); var addressQuery = from address in repository.CreateQuery <IAddress>() where address.Address1 == address1 select address; var getAddress = addressQuery.ToList().First(); repository.Delete(getAddress); }
private void button1_Click(object sender, EventArgs e) { var repository = new SDataEntityRepository(SDATA_CONTRACT_URL, SDATA_USERNAME, SDATA_PASSWORD); IQueryable<IContact> query = from contact in repository.CreateQuery<IContact>() where contact.FirstName == txtFirstNameSearch.Text //&& contact.YearGraduated > 1960 select contact; _contactList = query.ToList(); if (_contactList.Count == 0) Text = "No matching entities found"; //var accountList = (from account in repository.CreateQuery<IAccount>() // where account.Employees > 200 // select account).ToList(); ////Projecting anonymous type //var miniContacts = from contact in repository.CreateQuery<IContact>() // where contact.FirstName == txtFirstNameSearch.Text // select new { FN = contact.FirstName, LN = contact.LastName }; //var miniList1 = miniContacts.ToList(); ////query using extension methods //miniContacts = repository.CreateQuery<IContact>() // .Where(contact2 => contact2.FirstName == txtFirstNameSearch.Text) // .Select(contact2 => new { FN = contact2.FirstName, LN = contact2.LastName }); //var miniList2 = miniContacts.ToList(); ////project anonymous type with string concatenation //var contactNames = (from contact3 in repository.CreateQuery<IContact>() // select new { FullName = contact3.FirstName + " " + contact3.LastName }).ToList(); //var contactFullNameList = contactNames.ToList(); ////get by Id var contactById = repository.GetEntityById<IContact>("CA2EK0013122"); //lazy loaded relationship var accountName = contactById.Account.AccountName; var street = contactById.Account.Address.Address1; _contactIndex = 0; BindCurrentEntity(); }