Ejemplo n.º 1
0
        public static int Count(string name, string collection, IEnumerable <KeyValuePair <string, string> > keyValues)
        {
            XElement schema = GetSchema(name, GetDeltaSchemaKey(keyValues));
            string   filter = GetValue(keyValues, "$filter");

            return(ODataQuerier.Count(name, schema, GetEntity(schema, collection), filter, GetParameterValues(keyValues)));
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        public UsersService(string name)
        {
            Name         = name;
            Schema       = new SchemaProvider(name).GetSchema();
            ODataQuerier = ODataQuerier <XElement> .Create(Name, Schema);

            Modifier = XmlModifierFactory.Create(name, Schema);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 public static DateTime GetUtcNow(string name)
 {
     return(ODataQuerier.GetUtcNow(name));
 }