示例#1
0
        public void WhereById()
        {
            var result = SimpleClassDataContract.CreateQuery().OData().Filter($"{nameof(SimpleClassDataContract.Id)} eq 1").ToArray();

            Assert.Single(result);
            Assert.Equal(1, result[0].Id);
        }
示例#2
0
        public void WhereByChangedName()
        {
            var result = SimpleClassDataContract.CreateQuery().OData().Filter("nameChanged eq 'n1'").ToArray();

            Assert.Single(result);
            Assert.Equal(1, result[0].Id);
        }
        public void SelectDataMember()
        {
            ISelectExpandWrapper[] result = SimpleClassDataContract.CreateQuery().OData().SelectExpand("nameChanged").ToArray();

            IDictionary <string, object> metadata = result[0].ToDictionary();

            // Expect Name to be selected
            Assert.Equal(1, metadata.Count);
            Assert.Equal("nameChanged", metadata.Single().Key);
            Assert.Equal("n1", metadata.Single().Value);
            Assert.IsType <string>(metadata.Single().Value);
        }
示例#4
0
 public void WhereByNotMarkedThrowException()
 {
     Assert.Throws <ODataException>(() => SimpleClassDataContract.CreateQuery().OData()
                                    .Filter($"{nameof(SimpleClassDataContract.NameNotMarked)} eq 'nm1'"));
 }
示例#5
0
 public void WhereByIgnoredMemberThrowException()
 {
     Assert.Throws <ODataException>(() => SimpleClassDataContract.CreateQuery().OData()
                                    .Filter($"{nameof(SimpleClassDataContract.NameToIgnore)} eq 'ign1'"));
 }