Esempio n. 1
0
 public hidServices(DbContext dbc)
 {
     db        = dbc;
     PKName    = DbContextMetadata.FindPrimaryKey <T>(db).ToArray()[0].ToString();
     TableName = DbContextMetadata.FindTableName <T>(db);
     repo      = new GenericRepository <T>(db);
 }
Esempio n. 2
0
		public void DumpFixedUpScrumDbEdmx()
		{
			DbContextMetadata<ScrumDb> dbContextMetadata;

			using (var db = new ScrumDb())
			{
				dbContextMetadata = new DbContextMetadata<ScrumDb>(db);
			}
			IEdmModel edmModel = dbContextMetadata.EdmModel;

			var xmlSettings = new XmlWriterSettings() { Indent = true };
			IEnumerable<EdmError> writeErrors;
			using (XmlWriter writer = XmlWriter.Create(Console.Out, xmlSettings))
			{
				Microsoft.Data.Edm.Csdl.EdmxWriter.TryWriteEdmx(edmModel, writer, EdmxTarget.OData, out writeErrors);
			}

			if (writeErrors.Any())
			{
				Console.WriteLine();
				Console.WriteLine("EDMX write errors:");
				foreach (var error in writeErrors)
				{
					Console.WriteLine(error.ToString());
				}
			}
		}
Esempio n. 3
0
        public void DumpFixedUpScrumDbEdmx()
        {
            DbContextMetadata <ScrumDb> dbContextMetadata;

            using (var db = new ScrumDb())
            {
                dbContextMetadata = new DbContextMetadata <ScrumDb>(db);
            }
            IEdmModel edmModel = dbContextMetadata.EdmModel;

            var xmlSettings = new XmlWriterSettings()
            {
                Indent = true
            };
            IEnumerable <EdmError> writeErrors;

            using (XmlWriter writer = XmlWriter.Create(Console.Out, xmlSettings))
            {
                Microsoft.Data.Edm.Csdl.EdmxWriter.TryWriteEdmx(edmModel, writer, EdmxTarget.OData, out writeErrors);
            }

            if (writeErrors.Any())
            {
                Console.WriteLine();
                Console.WriteLine("EDMX write errors:");
                foreach (var error in writeErrors)
                {
                    Console.WriteLine(error.ToString());
                }
            }
        }
Esempio n. 4
0
        public void DumpFixedDbContextEntityDataModel()
        {
            string edmXml;

            using (EStoreDb db = new EStoreDb())
            {
                var       dbContextMetadata = new DbContextMetadata <EStoreDb>(db);
                IEdmModel edm = dbContextMetadata.EdmModel;

                edm.RemoveClrTypeAnnotations();
                edmXml = DumpEdm(edm);

                //foreach (var elt in edm.SchemaElements)
                //{
                //	var directValueAnnotations = edm.DirectValueAnnotationsManager.GetDirectValueAnnotations(elt).ToArray();
                //	var vocabularyAnnotations = edm.FindDeclaredVocabularyAnnotations(elt).ToArray();
                //	_testOutput.WriteLine("{0} has {1} DirectValueAnnotations; {2} VocabularyAnnotations", elt.FullName(), directValueAnnotations.Length, vocabularyAnnotations.Length);
                //}
            }

            Assert.DoesNotContain("ClrType", edmXml);
            Assert.DoesNotContain("__", edmXml);
        }
		public void DumpFixedDbContextEntityDataModel()
		{
			string edmXml;

			using (EStoreDb db = new EStoreDb())
			{
				var dbContextMetadata = new DbContextMetadata<EStoreDb>(db);
				IEdmModel edm = dbContextMetadata.EdmModel;

				edm.RemoveClrTypeAnnotations();
				edmXml = DumpEdm(edm);

				//foreach (var elt in edm.SchemaElements)
				//{
				//	var directValueAnnotations = edm.DirectValueAnnotationsManager.GetDirectValueAnnotations(elt).ToArray();
				//	var vocabularyAnnotations = edm.FindDeclaredVocabularyAnnotations(elt).ToArray();
				//	_testOutput.WriteLine("{0} has {1} DirectValueAnnotations; {2} VocabularyAnnotations", elt.FullName(), directValueAnnotations.Length, vocabularyAnnotations.Length);
				//}

			}

			Assert.DoesNotContain("ClrType", edmXml);
			Assert.DoesNotContain("__", edmXml);
		}