예제 #1
0
        public void TestWhereSelect()
        {
            var repository = new RepositoryMsSql <DictInfo>(Conn);
            var rst        = repository.WhereSelect(x => x.DictID >= 106071, x => x.DictName);//投影查询(只查询某些字段)可投影为匿名类型
            var rstfull    = repository.Where(x => x.DictID >= 106071);

            Assert.False(0 == rstfull.Count);
            Assert.Equal(rst.Count, rstfull.Count);
            bool r = rst.Contains(rstfull.First().DictName);

            Assert.True(r);

            var ll2 = repository.WhereSelect(x => x.DictName.Contains("哈哈") && x.Deleted, x => new { x.DictName, x.DictID }).ToDictionary(x => x.DictID, x => x.DictName);
        }
예제 #2
0
        public void TestWhereSelectDistinct()
        {
            IRepository <DictInfo> repository = new RepositoryMsSql <DictInfo>(Conn);
            var resultNoDistinct = repository.WhereSelect(x => true, x => x.DictName);
            var resultDistinct   = repository.WhereSelectDistinct(x => true, x => x.DictName);

            foreach (var item in resultDistinct)
            {
                bool b = resultNoDistinct.Contains(item);
                Assert.True(b);
            }
            Assert.True(resultDistinct.Count <= resultNoDistinct.Count);
        }