public GetTestModelSpecification(
     TestQueryModel query
     , int[] filterByIds)
     : this(x => x.Name.LikeOrNull(query.Name) &&
            x.ParentId.EqualsOrNull(query.ParentId) &&
            filterByIds.ContainsOrNull(x.Id))
 {
     /*
      * (((x.name LIKE @Name) OR (@Name IS NULL)) AND ((x.parent_id = @ParentId) OR (@ParentId IS NULL)) AND (x.Id IN @IdCollection) OR (@IdCollection IS NULL)))
      */
 }
        public void GivenGetOrganizationSpecification2_ResultIsValidWhereExpression()
        {
            var query        = new TestQueryModel();
            var idCollection = new int[] { };
            var spec         = new GetTestModelSpecification(query, idCollection);
            var parser       = Parser.GetParser(spec.Expression);
            var node         = parser.Parse();
            var result       = Parser.CreateResult(node, mapping);

            //SubModel.Name => s.name

            Assert.AreEqual(@"((((m.name LIKE '%' + @Name + '%') OR (@Name IS NULL)) AND ((m.parent_id = @ParentId) OR (@ParentId IS NULL))) AND (1 = 1))", result.ResultExpression);

            var parametes = result.Parameters.ToDictionary(x => x.Name, x => x.Value);

            Assert.IsTrue(parametes.Count == 2);
            Assert.IsTrue(parametes.ContainsKey("Name"));
            Assert.IsTrue(parametes.ContainsKey("ParentId"));

            Assert.AreEqual(parametes["Name"], query.Name, "Параметр Name не соответсвует значениею query.Name");
            Assert.AreEqual(parametes["ParentId"], query.ParentId);
        }