示例#1
0
        public void When_Stored_With_Newtonsoft_And_Fetched_With_STJ_Should_Succeed()
        {
            StoreOptions(options =>
            {
                options.UseDefaultSerialization(serializerType: SerializerType.Newtonsoft);

                options.Schema.For <BigIntegerObject>()
                .Duplicate(x => x.Value);
            });

            using (var session = theStore.OpenSession())
            {
                var obj = new BigIntegerObject {
                    Id = 1, Value = BigInteger.Parse(LargerThanLongValue)
                };

                session.Store(obj);
                session.SaveChanges();
            }

            StoreOptions(options =>
            {
                options.UseDefaultSerialization(serializerType: SerializerType.SystemTextJson);

                options.Schema.For <BigIntegerObject>()
                .Duplicate(x => x.Value);
            }, false);

            using (var session = theStore.OpenSession())
            {
                var result = session.Load <BigIntegerObject>(1);

                result.Value.ToString().ShouldBe(LargerThanLongValue);
            }
        }
示例#2
0
        public void When_Querying_Using_SystemTextJson_Should_Persist_And_Fetch_BigInteger_Values()
        {
            StoreOptions(options =>
            {
                options.UseDefaultSerialization(serializerType: SerializerType.SystemTextJson);

                options.Schema.For <BigIntegerObject>()
                .Duplicate(x => x.Value);
            });

            using (var session = theStore.OpenSession())
            {
                var obj = new BigIntegerObject {
                    Id = 1, Value = BigInteger.Parse(LargerThanLongValue)
                };

                session.Store(obj);
                session.SaveChanges();
            }

            using (var session = theStore.OpenSession())
            {
                var result = session.Load <BigIntegerObject>(1);

                result.Value.ToString().ShouldBe(LargerThanLongValue);
            }
        }