public void DeleteFromRepository(UdListItem udListItem) { if (_repositoryContext.GetEntityDescriptor(udListItem) != null) { //if it exists in the db delete it from the db UdListEntities context = new UdListEntities(_rootUri); context.MergeOption = MergeOption.AppendOnly; context.IgnoreResourceNotFoundException = true; UdListItem deletequery = (from q in context.UdListItems where q.UdListItemID == udListItem.UdListItemID && q.CompanyID == udListItem.CompanyID select q).FirstOrDefault(); if (deletequery != null) { context.DeleteObject(deletequery); context.SaveChanges(); } context = null; _repositoryContext.MergeOption = MergeOption.AppendOnly; //if it is being tracked remove it... if (GetUdListItemEntityState(udListItem) != EntityStates.Detached) { _repositoryContext.Detach(udListItem); } } }
private UdListSingletonRepository() { ServiceUtility serviceUtility = new ServiceUtility(); _rootUri = serviceUtility.BaseUri; _repositoryContext = new UdListEntities(_rootUri); }
public static List <Temp> GetMetaData(this UdListItem entityObject) { XERP.Server.DAL.UdListDAL.DALUtility dalUtility = new DALUtility(); List <Temp> tempList = new List <Temp>(); int id = 0; using (UdListEntities ctx = new UdListEntities(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 UdListServiceAgent() { ServiceUtility serviceUtility = new ServiceUtility(); _rootUri = serviceUtility.BaseUri; //this context will be used for read only gets... _context = new UdListEntities(_rootUri); _context.MergeOption = MergeOption.NoTracking; }
public IEnumerable <UdList> Refresh(string autoIDs) { _repositoryContext = new UdListEntities(_rootUri); _repositoryContext.MergeOption = MergeOption.AppendOnly; _repositoryContext.IgnoreResourceNotFoundException = true; var queryResult = _repositoryContext.CreateQuery <UdList>("RefreshUdList").Expand("UdListItems").AddQueryOption("autoIDs", "'" + autoIDs + "'"); return(queryResult); }
public IEnumerable <UdList> GetUdLists(string companyID) { _repositoryContext = new UdListEntities(_rootUri); _repositoryContext.MergeOption = MergeOption.AppendOnly; _repositoryContext.IgnoreResourceNotFoundException = true; var queryResult = (from q in _repositoryContext.UdLists.Expand("UdListItems") where q.CompanyID == companyID select q); return(queryResult); }
public IEnumerable <UdList> GetUdLists(UdList udListQuerryObject, string companyID) { _repositoryContext = new UdListEntities(_rootUri); _repositoryContext.MergeOption = MergeOption.AppendOnly; _repositoryContext.IgnoreResourceNotFoundException = true; var queryResult = from q in _repositoryContext.UdLists.Expand("UdListItems") where q.CompanyID == companyID select q; if (!string.IsNullOrEmpty(udListQuerryObject.Name)) { queryResult = queryResult.Where(q => q.Name.StartsWith(udListQuerryObject.Name.ToString())); } if (!string.IsNullOrEmpty(udListQuerryObject.Description)) { queryResult = queryResult.Where(q => q.Description.StartsWith(udListQuerryObject.Description.ToString())); } return(queryResult); }