Пример #1
0
        public override void ShouldLoadEntities()
        {
            Mapping mapping = Mapping.Load(Path.Combine(mappingFolder, "Composite/mapping.xml"));

            ObjectService os = new ObjectService(GetProvider(mapping));
            IObjectContext oc = os.CreateObjectContext();

            oc.InitializeRepository();

            oc.BeginTransaction();
            oc.Serialize(new Person() { FirstName = "test", Address = new Address() { City = "test" } });
            oc.CommitTransaction();

            oc.Clear();

            IList<Person> person = ((IInferrable<Person>)from Person p in oc select p).ToList();

            Assert.AreEqual(1, person.Count);

            Assert.IsNotNull(person.FirstOrDefault());

            Assert.AreEqual("test", person.First().FirstName);

            Assert.AreEqual(person.First().FirstName, person.First().LastName);

            Assert.IsNotNull(person.First().Address);

            Assert.AreEqual("test", person.First().Address.City);
        }
Пример #2
0
 protected override IObjectContext CreateContext()
 {
     OData.ODataPersistenceProvider provider = new OData.ODataPersistenceProvider();
     provider.ConnectionString = new Uri("http://localhost:37770/Common.svc/");
     os = new ObjectService(provider);
     os.ObjectContextType = typeof(EntityResolver.Proxy.Dynamic.ObjectContext).AssemblyQualifiedName;
     return os.CreateObjectContext();
 }
Пример #3
0
        public void ShouldWorkWithHighLayer()
        {
            IPersistenceProvider provider = new SqlMapper.SqlMapperProvider();
            ((SqlMapper.SqlMapperProvider)provider).ConnectionString = "Data Source=.;Initial Catalog=uss2;Integrated Security=true";
            ((SqlMapper.SqlMapperProvider)provider).UseDefaultMapping = true;
            provider.RegisterMetaData(MetaData.MetaDataFactory.FromAssembly(GetType().Assembly, "Evaluant.Uss.Tests.Model"));
            provider.InitializeConfiguration();
            ObjectService os = new ObjectService(provider);
            os.ObjectContextType = typeof(EntityResolver.Proxy.Dynamic.ObjectContext).AssemblyQualifiedName;
            IObjectContext context = os.CreateObjectContext();
            context.InitializeRepository();
            context.BeginTransaction();
            context.Serialize(new Address() { City = "Mulhouse" });
            context.CommitTransaction();

            context = os.CreateObjectContext();
            var addresses = context.Load<Address>();

            if (addresses.Count > 0)
            {
                Address a = addresses.First();
                Assert.AreEqual("Mulhouse", a.City);
            }

            var addresses2 = (from Address a in context select a).ToList();

            Assert.AreEqual(addresses.FirstOrDefault(), addresses2.FirstOrDefault());
        }