public Element Get(string name, string category, string culture) { var entity = new LabelEntity(SiteName, name, "", category); return(CloudTableHelper.GetTableServiceContext().CreateQuery <LabelEntity>(LabelTable) .Where(it => it.PartitionKey == entity.SiteName && it.RowKey == entity.RowKey) .ToArray() .Select(it => it.ToElement()) .FirstOrDefault()); }
public bool Remove(Element element) { var entity = new LabelEntity(SiteName, element); var serviceContext = CloudTableHelper.GetTableServiceContext(); entity = serviceContext.CreateQuery <LabelEntity>(LabelTable) .Where(it => it.PartitionKey == SiteName && it.RowKey == entity.RowKey) .FirstOrDefault(); if (entity != null) { serviceContext.DeleteObject(entity); serviceContext.SaveChangesWithRetries(); } return(true); }
private void InsertOrUpdateLabel(Element @new, Element old) { var serviceContext = CloudTableHelper.GetTableServiceContext(); var entity = new LabelEntity(SiteName, @new); if (Get(old.Name, old.Category, old.Culture) == null) { if (!string.IsNullOrEmpty(@new.Category)) { AddCategory(@new.Category, @new.Culture); } serviceContext.AddObject(LabelTable, entity); } else { serviceContext.AttachTo(LabelTable, entity, "*"); serviceContext.UpdateObject(entity); } serviceContext.SaveChangesWithRetries(); }
public Element Get(string name, string category, string culture) { var entity = new LabelEntity(SiteName, name, "", category); return CloudTableHelper.GetTableServiceContext().CreateQuery<LabelEntity>(LabelTable) .Where(it => it.PartitionKey == entity.SiteName && it.RowKey == entity.RowKey) .ToArray() .Select(it => it.ToElement()) .FirstOrDefault(); }
private void InsertOrUpdateLabel(Element @new, Element old) { var serviceContext = CloudTableHelper.GetTableServiceContext(); var entity = new LabelEntity(SiteName, @new); if (Get(old.Name, old.Category, old.Culture) == null) { if (!string.IsNullOrEmpty(@new.Category)) { AddCategory(@new.Category, @new.Culture); } serviceContext.AddObject(LabelTable, entity); } else { serviceContext.AttachTo(LabelTable, entity, "*"); serviceContext.UpdateObject(entity); } serviceContext.SaveChangesWithRetries(); }
public bool Remove(Element element) { var entity = new LabelEntity(SiteName, element); var serviceContext = CloudTableHelper.GetTableServiceContext(); entity = serviceContext.CreateQuery<LabelEntity>(LabelTable) .Where(it => it.PartitionKey == SiteName && it.RowKey == entity.RowKey) .FirstOrDefault(); if (entity != null) { serviceContext.DeleteObject(entity); serviceContext.SaveChangesWithRetries(); } return true; }