Beispiel #1
0
        public IDocumentFinderQueryBuilder WhereEquals <T1, T2>(Expression <Func <T1, T2> > property, T2 value) where T1 : class
        {
            var path = DocumentPropertyPathProvider.GetFor(property);

            Criteria.Add(d =>
            {
                var a = DocumentPropertyFinder.GetFor(d, path);

                if (a == null)
                {
                    if (value == null)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                return(a.Equals(value));
            });

            return(this);
        }
Beispiel #2
0
        public IDocumentFinderQueryBuilder WhereExists <T1, T2>(Expression <Func <T1, T2> > property) where T1 : class
        {
            var path = DocumentPropertyPathProvider.GetFor(property);

            Criteria.Add(d => DocumentPropertyFinder.Exists(d, path));

            return(this);
        }
Beispiel #3
0
        public void DetectsExistingGlobalFacetCoreInterfaceProperty()
        {
            var value = new object();

            var document = new Document {
                GlobalFacet = new DocumentFacet {
                    Interfaces = new Dictionary <string, DocumentInterface> {
                        ["MyCoreInterface"] = new DocumentInterface {
                            Properties = new Dictionary <string, object> {
                                ["MyProperty"] = value
                            }
                        }
                    }
                }
            };

            var result = new DocumentPropertyFinder().Exists(document, "GlobalFacet.Interfaces.MyCoreInterface.Properties.MyProperty");

            Assert.True(result);
        }
Beispiel #4
0
        public void FindsGlobalFacetCoreInterfaceProperty()
        {
            var value = new object();

            var document = new Document {
                GlobalFacet = new DocumentFacet {
                    Interfaces = new Dictionary <string, DocumentInterface> {
                        ["MyCoreInterface"] = new DocumentInterface {
                            Properties = new Dictionary <string, object> {
                                ["MyProperty"] = value
                            }
                        }
                    }
                }
            };

            var result = new DocumentPropertyFinder().GetFor(document, "GlobalFacet.Interfaces.MyCoreInterface.Properties.MyProperty");

            Assert.Same(value, result);
        }
Beispiel #5
0
        public IDocumentFinderQueryBuilder WhereIn <T1, T2>(Expression <Func <T1, T2> > property, IEnumerable <T2> values) where T1 : class
        {
            var path = DocumentPropertyPathProvider.GetFor(property);

            Criteria.Add(d =>
            {
                var a = DocumentPropertyFinder.GetFor(d, path);

                if (a == null)
                {
                    return(false);
                }

                if (!(a is T2))
                {
                    return(false);
                }

                return(values.Contains((T2)a));
            });

            return(this);
        }