Exemplo n.º 1
0
        public void TestWhereAndFind()
        {
            var repository = new RepositoryMsSql <DictInfo>(Conn);
            var rst        = repository.Where(x => x.DictID > 106087);
            var model      = repository.Find(106088);//Find 是根据主键获取记录,所以主键上要有 Key标记。

            Assert.Equal(model.Remark, rst.Find(x => x.DictID == 106088)?.Remark);
        }
Exemplo n.º 2
0
        public void TestWhereWithSomeFields()
        {
            var repository = new RepositoryMsSql <DictInfo>(Conn);
            var rst        = repository.Where(x => x.CreateTime > new DateTime(2018, 12, 1), x => x.DictID, x => x.DictName);//只查询 DictID DictName 两个字段

            Assert.False(0 == rst.Count);
            Assert.Equal(0, rst.Count(x => !string.IsNullOrEmpty(x.Remark)));
            var first = rst.First();
            var model = repository.Find(first.DictID);

            Assert.Equal(first.DictName, model.DictName);
        }