コード例 #1
0
        public void BasicEqualityExpression()
        {
            using (var context = new BloggingContext(GetDbOptions()))
            {
                context.Blogs.Add(new Blog {
                    Url = "http://test.com"
                });
                context.SaveChanges();

                var testBlog = context.Blogs.FirstOrDefault(b => b.Url == "http://test.com");

                var  fields = Mre.Member.GetFields(typeof(Blog));
                Rule rule   = new Rule
                {
                    MemberName  = "Url",
                    Operator    = MreOperator.Equal.ToString("g"),
                    TargetValue = "http://test.com"
                };

                var blog2 = context.Blogs.Where(Mre.ToExpression <Blog>(rule, false)).FirstOrDefault();

                Assert.IsTrue(testBlog.BlogId == blog2.BlogId);
            }
        }