public void DeleteFromRepository(Address address) { if (_repositoryContext.GetEntityDescriptor(address) != null) {//if it exists in the db delete it from the db AddressEntities context = new AddressEntities(_rootUri); context.MergeOption = MergeOption.AppendOnly; context.IgnoreResourceNotFoundException = true; Address deletedAddress = (from q in context.Addresses where q.AddressID == address.AddressID select q).FirstOrDefault(); if (deletedAddress != null) { context.DeleteObject(deletedAddress); context.SaveChanges(); } context = null; _repositoryContext.MergeOption = MergeOption.AppendOnly; //if it is being tracked remove it... if (GetAddressEntityState(address) != EntityStates.Detached) { _repositoryContext.Detach(address); } } }
private AddressSingletonRepository() { ServiceUtility serviceUtility = new ServiceUtility(); _rootUri = serviceUtility.BaseUri; _repositoryContext = new AddressEntities(_rootUri); }
public static List <Temp> GetMetaData(this Address entityObject) { XERP.Server.DAL.AddressDAL.DALUtility dalUtility = new DALUtility(); List <Temp> tempList = new List <Temp>(); int id = 0; using (AddressEntities ctx = new AddressEntities(dalUtility.EntityConectionString)) { var c = ctx.Companies.FirstOrDefault(); var queryResults = from meta in ctx.MetadataWorkspace.GetItems(DataSpace.CSpace) .Where(m => m.BuiltInTypeKind == BuiltInTypeKind.EntityType) from query in (meta as EntityType).Properties .Where(p => p.DeclaringType.Name == entityObject.GetType().Name) select query; if (queryResults.Count() > 0) { foreach (var queryResult in queryResults.ToList()) { Temp temp = new Temp(); temp.ID = id; temp.Name = queryResult.Name.ToString(); temp.ShortChar_1 = queryResult.TypeUsage.EdmType.Name; if (queryResult.TypeUsage.EdmType.Name == "String") { temp.Int_1 = Convert.ToInt32(queryResult.TypeUsage.Facets["MaxLength"].Value); } temp.Bool_1 = false; //we use this as a error trigger false = not an error... tempList.Add(temp); id++; } } } return(tempList); }
public AddressServiceAgent() { ServiceUtility serviceUtility = new ServiceUtility(); _rootUri = serviceUtility.BaseUri; //this context will be used for read only gets... _context = new AddressEntities(_rootUri); _context.MergeOption = MergeOption.NoTracking; }
public IEnumerable <Address> Refresh(string autoIDs) { _repositoryContext = new AddressEntities(_rootUri); _repositoryContext.MergeOption = MergeOption.AppendOnly; _repositoryContext.IgnoreResourceNotFoundException = true; var queryResult = _repositoryContext.CreateQuery <Address>("RefreshAddress").AddQueryOption("autoIDs", "'" + autoIDs + "'"); return(queryResult); }
public IEnumerable <Address> GetAddresses(string companyID) { _repositoryContext = new AddressEntities(_rootUri); _repositoryContext.MergeOption = MergeOption.AppendOnly; _repositoryContext.IgnoreResourceNotFoundException = true; var queryResult = (from q in _repositoryContext.Addresses where q.CompanyID == companyID select q); return(queryResult); }
public IEnumerable <Address> GetAddresses(Address addressQuerryObject, string companyID) { _repositoryContext = new AddressEntities(_rootUri); _repositoryContext.MergeOption = MergeOption.AppendOnly; _repositoryContext.IgnoreResourceNotFoundException = true; var queryResult = from q in _repositoryContext.Addresses where q.CompanyID == companyID select q; if (!string.IsNullOrEmpty(addressQuerryObject.Name)) { queryResult = queryResult.Where(q => q.Name.StartsWith(addressQuerryObject.Name.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.Description)) { queryResult = queryResult.Where(q => q.Description.StartsWith(addressQuerryObject.Description.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.Address1)) { queryResult = queryResult.Where(q => q.Address1.StartsWith(addressQuerryObject.Address1.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.Address2)) { queryResult = queryResult.Where(q => q.Address2.StartsWith(addressQuerryObject.Address2.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.Address3)) { queryResult = queryResult.Where(q => q.Address3.StartsWith(addressQuerryObject.Address3.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.City)) { queryResult = queryResult.Where(q => q.City.StartsWith(addressQuerryObject.City.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.State)) { queryResult = queryResult.Where(q => q.State.StartsWith(addressQuerryObject.State.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.Zip)) { queryResult = queryResult.Where(q => q.Zip.StartsWith(addressQuerryObject.Zip.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.Country)) { queryResult = queryResult.Where(q => q.Country.StartsWith(addressQuerryObject.Country.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.PhoneNum)) { queryResult = queryResult.Where(q => q.PhoneNum.StartsWith(addressQuerryObject.PhoneNum.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.PhoneNum2)) { queryResult = queryResult.Where(q => q.PhoneNum2.StartsWith(addressQuerryObject.PhoneNum2.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.FaxNum)) { queryResult = queryResult.Where(q => q.FaxNum.StartsWith(addressQuerryObject.FaxNum.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.Email)) { queryResult = queryResult.Where(q => q.Email.StartsWith(addressQuerryObject.Email.ToString())); } if (!string.IsNullOrEmpty(addressQuerryObject.Email2)) { queryResult = queryResult.Where(q => q.Email2.StartsWith(addressQuerryObject.Email2.ToString())); } return(queryResult); }
public AddressBookRepository(AddressEntities addressEntities) { this.addressEntities = addressEntities; }