public XmlService(string name, IEnumerable <KeyValuePair <string, string> > keyValues) : base(name, keyValues) { Modifier = XmlModifierFactory.Create(name); Database = Modifier.Database; ODataQuerier = ODataQuerier <XElement> .Create(Name, Schema); }
public UsersService(string name) { Name = name; Schema = new SchemaProvider(name).GetSchema(); ODataQuerier = ODataQuerier <XElement> .Create(Name, Schema); Modifier = XmlModifierFactory.Create(name, Schema); }
public bool Exists(string entity, IEnumerable <KeyValuePair <string, object> > propertyValues) { string filter = GenerateFilter(propertyValues, out IReadOnlyDictionary <string, object> parameters); string select = propertyValues.First().Key; ODataQuerier <XElement> oDataQuerier = ODataQuerier <XElement> .Create(Name, Schema); IEnumerable <XElement> result = oDataQuerier.GetCollection(entity, select, filter, null, parameters); return(result.Count() > 0); }
public bool IsUnique(string entity, IEnumerable <KeyValuePair <string, object> > propertyValues, IEnumerable <KeyValuePair <string, object> > excludedKey) { string filter = GenerateFilter(propertyValues, out IReadOnlyDictionary <string, object> parameters); string select = string.Join(",", excludedKey.Select(p => p.Key)); ODataQuerier <XElement> oDataQuerier = ODataQuerier <XElement> .Create(Name, Schema); IEnumerable <XElement> result = oDataQuerier.GetCollection(entity, select, filter, null, parameters); int count = result.Count(); if (count == 0) { return(true); } if (count > 1) { return(false); } XElement element = result.First(); foreach (KeyValuePair <string, object> pair in excludedKey) { object obj = pair.Value; string value; if (obj.GetType() == typeof(bool)) { value = ((bool)obj) ? "true" : "false"; } else if (obj.GetType() == typeof(DateTime)) { value = new DotNETDateFormatter().Format((DateTime)obj); } else { value = obj.ToString(); } if (element.Element(pair.Key).Value == value) { continue; } return(false); } return(true); }