Example #1
0
        public void And()
        {
            // select from Person where FirstName='John' and LastName='Doe'
            var filter = new Extent(M.Person.ObjectType)
            {
                Predicate = new And
                {
                    Operands = new IPredicate[]
                    {
                        new Equals
                        {
                            PropertyType = M.Person.FirstName,
                            Value        = "John",
                        },
                        new Equals
                        {
                            PropertyType = M.Person.LastName,
                            Value        = "Doe"
                        },
                    },
                },
            };

            var queryExtent = filter.Build(this.Session);

            var extent = this.Session.Extent(M.Person.ObjectType);
            var and    = extent.Filter.AddAnd();

            and.AddEquals(M.Person.FirstName, "John");
            and.AddEquals(M.Person.LastName, "Doe");

            Assert.Equal(extent.ToArray(), queryExtent.ToArray());
        }
Example #2
0
        public Fetch Get(Guid id)
        {
            if (!this.fetchById.TryGetValue(id, out var fetch))
            {
                using (var session = this.databaseService.Database.CreateSession())
                {
                    var filter = new Extent(M.PreparedFetch.Class)
                    {
                        Predicate = new Equals(M.PreparedFetch.UniqueId.RoleType)
                        {
                            Value = id
                        },
                    };

                    var preparedFetch = (PreparedFetch)filter.Build(session).First;
                    if (preparedFetch != null)
                    {
                        fetch = preparedFetch.Fetch;
                        this.fetchById[id] = fetch;
                    }
                }
            }

            return(fetch);
        }
Example #3
0
        public IExtent Get(Guid id)
        {
            if (!this.extentById.TryGetValue(id, out var extent))
            {
                using (var session = this.databaseService.Database.CreateSession())
                {
                    var filter = new Extent(M.PreparedExtent.Class)
                    {
                        Predicate = new Equals(M.PreparedExtent.UniqueId.RoleType)
                        {
                            Value = id
                        },
                    };

                    var preparedExtent = (PreparedExtent)filter.Build(session).First;
                    if (preparedExtent != null)
                    {
                        extent = preparedExtent.Extent;
                        this.extentById[id] = extent;
                    }
                }
            }

            return(extent);
        }
Example #4
0
        public void Type()
        {
            var query       = new Extent(M.Person.ObjectType);
            var queryExtent = query.Build(this.Session);

            var extent = this.Session.Extent(M.Person.ObjectType);

            Assert.Equal(extent.ToArray(), queryExtent.ToArray());
        }
Example #5
0
        public void RoleEquals()
        {
            var filter = new Extent(M.Person.ObjectType)
            {
                Predicate = new Equals
                {
                    PropertyType = M.Person.FirstName,
                    Value        = "John",
                },
            };

            var queryExtent = filter.Build(this.Session);

            var extent = this.Session.Extent(M.Person.ObjectType);

            extent.Filter.AddEquals(M.Person.FirstName, "John");

            Assert.Equal(extent.ToArray(), queryExtent.ToArray());
        }