Ejemplo n.º 1
0
        public IHttpActionResult PutProduct(int id, Product product)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != product.ProductID)
            {
                return(BadRequest());
            }

            AdventureWorks.Entry(product).State = EntityState.Modified;

            try
            {
                AdventureWorks.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 internal static void Dispose()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         // Unit of work.
     }
 }
        public IHttpActionResult PutSalesPerson(int id, SalesPerson salesPerson)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != salesPerson.BusinessEntityID)
            {
                return(BadRequest());
            }

            AdventureWorks.Entry(salesPerson).State = EntityState.Modified;

            try
            {
                AdventureWorks.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SalesPersonExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public void ModelDefinedFunctionInLinqTest()
        {
            using (AdventureWorks database = new AdventureWorks())
            {
                var employees = from employee in database.Persons
                                where employee.Title != null
                                let formatted = employee.FormatName()
                                                select new
                {
                    formatted,
                    employee
                };
                var employeeData = employees.Take(1).ToList().FirstOrDefault();
                Assert.NotNull(employeeData);
                Assert.NotNull(employeeData.formatted);
                Assert.Equal(employeeData.employee.FormatName(), employeeData.formatted);
            }

            using (AdventureWorks database = new AdventureWorks())
            {
                var employees = from employee in database.Persons
                                where employee.Title != null
                                select new
                {
                    Decimal = employee.ParseDecimal(),
                    Int32   = employee.BusinessEntityID
                };
                var employeeData = employees.Take(1).ToList().FirstOrDefault();
                Assert.NotNull(employeeData);
                Assert.Equal(employeeData.Decimal, Convert.ToInt32(employeeData.Int32));
            }
        }
Ejemplo n.º 5
0
 internal static void Rollback(Action <AdventureWorks, AdventureWorks, AdventureWorks> action, string connectionString = null)
 {
     using (DbConnection connection = new SqlConnection(connectionString ?? DefaultConnection))
     {
         connection.Open();
         using (AdventureWorks adventureWorks1 = new AdventureWorks(connection))
             using (AdventureWorks adventureWorks2 = new AdventureWorks(connection))
                 using (AdventureWorks adventureWorks3 = new AdventureWorks(connection))
                 {
                     adventureWorks1.Database.CreateExecutionStrategy().Execute(() =>
                     {
                         adventureWorks2.Database.CreateExecutionStrategy().Execute(() =>
                         {
                             adventureWorks3.Database.CreateExecutionStrategy().Execute(() =>
                             {
                                 using (DbTransaction transaction = connection.BeginTransaction())
                                 {
                                     try
                                     {
                                         adventureWorks1.Database.UseTransaction(transaction);
                                         adventureWorks2.Database.UseTransaction(transaction);
                                         adventureWorks3.Database.UseTransaction(transaction);
                                         action(adventureWorks1, adventureWorks2, adventureWorks3);
                                     }
                                     finally
                                     {
                                         transaction.Rollback();
                                     }
                                 }
                             });
                         });
                     });
                 }
     }
 }
 public void NiladicFunctionLinqTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         var firstCategory = adventureWorks.ProductSubcategories
                             .GroupBy(subcategory => subcategory.ProductCategoryID)
                             .Select(category => new
         {
             CategoryId       = category.Key,
             SubcategoryNames = category.Select(subcategory => subcategory.Name.Left(4)).Concat(),
             CurrentTimestamp = NiladicFunctions.CurrentTimestamp(),
             CurrentUser      = NiladicFunctions.CurrentUser(),
             SessionUser      = NiladicFunctions.SessionUser(),
             SystemUser       = NiladicFunctions.SystemUser(),
             User             = NiladicFunctions.User()
         })
                             .First();
         Assert.NotNull(firstCategory);
         Assert.NotNull(firstCategory.CurrentTimestamp);
         Trace.WriteLine(DateTime.Now.Ticks);
         Trace.WriteLine(firstCategory.CurrentTimestamp.Value.Ticks);
         Assert.True(DateTime.Now >= firstCategory.CurrentTimestamp);
         Assert.Equal("dbo", firstCategory.CurrentUser, true);
         Assert.Equal("dbo", firstCategory.SessionUser, true);
         Assert.Equal($@"{Environment.UserDomainName}\{Environment.UserName}", firstCategory.SystemUser, true);
         Assert.Equal("dbo", firstCategory.User, true);
     }
 }
Ejemplo n.º 7
0
 public void ContainerTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         Assert.AreEqual(nameof(AdventureWorks), adventureWorks.Container().Name);
     }
 }
Ejemplo n.º 8
0
 public ProductsController(
     AdventureWorks adventureWorks,
     ProductsViewModel productsViewModel)
 {
     AdventureWorks = adventureWorks;
     viewModel      = productsViewModel;
 }
        public IHttpActionResult PostSalesPerson(SalesPerson salesPerson)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            AdventureWorks.SalesPersons.Add(salesPerson);

            try
            {
                AdventureWorks.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (SalesPersonExists(salesPerson.BusinessEntityID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = salesPerson.BusinessEntityID }, salesPerson));
        }
Ejemplo n.º 10
0
        public void ManyToManyTest()
        {
            using (AdventureWorks adventureWorks = new AdventureWorks())
            {
                Product[] products = adventureWorks
                                     .Products
#if NETFX
                                     .Include(product => product.ProductProductPhotos.Select(productProductPhoto => productProductPhoto.ProductPhoto))
#else
                                     .Include(product => product.ProductProductPhotos).ThenInclude(productProductPhoto => productProductPhoto.ProductPhoto)
#endif
                                     .ToArray();
                EnumerableAssert.Multiple(products);
                EnumerableAssert.Any(products.Where(product => product.ProductProductPhotos.Any(productProductPhoto => productProductPhoto.ProductPhoto != null)));

                ProductPhoto[] photos = adventureWorks.ProductPhotos
#if NETFX
                                        .Include(photo => photo.ProductProductPhotos.Select(productProductPhoto => productProductPhoto.Product))
#else
                                        .Include(photo => photo.ProductProductPhotos).ThenInclude(productProductPhoto => productProductPhoto.Product)
#endif
                                        .ToArray();
                EnumerableAssert.Multiple(photos);
                Assert.IsTrue(photos.All(photo => photo.ProductProductPhotos.Any(productProductPhoto => productProductPhoto.Product != null)));
            }
        }
Ejemplo n.º 11
0
 public void TableValuedFunctionTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         IQueryable <ContactInformation> employees = adventureWorks.ufnGetContactInformation(1).Take(2);
         EnumerableAssert.Single(employees);
     }
 }
Ejemplo n.º 12
0
 public void CompiedQueryTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         string[] productNames = adventureWorks.GetProductNames(539.99M).ToArray();
         EnumerableAssert.Any(productNames);
     }
 }
Ejemplo n.º 13
0
 public void StoredProcedureWithSingleResultTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         ISingleResult <ManagerEmployee> employees = adventureWorks.uspGetManagerEmployees(2);
         EnumerableAssert.Any(employees);
     }
 }
Ejemplo n.º 14
0
        public void Invalid_add_field_path()
        {
            var aw = new AdventureWorks();
            var path = new FieldPath(aw.Products.DefaultField);

            // no link between normal field product.name and normal field contact.name
            Assert.Throws<InvalidOperationException>(() => { path.Add(aw.Contacts.DefaultField); });
        }
 public void StoredProcedureWithSingleResultTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         ObjectResult <ManagerEmployee> employees = adventureWorks.uspGetManagerEmployees(2);
         Assert.True(employees.Any());
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        ///  Gets the Adventure Works products.
        ///   </summary>
        ///   <returns> List of product objects (limited to 25 for demo), </returns>
        ///   <remarks>Returns a list of "light" DTOs, mapped with AutoMapper from the Product table</remarks>
        ///   <response code="200">OK</response>
        /// <response code="404">Not Found</response>
        /// <see cref="2sharp.today/api/swagger"/>

        //[ResponseType(typeof(Product))]
        public IHttpActionResult GetProducts()
        {
            using (var db = new AdventureWorks()) {
                var products = db.Products.Take(25).ToList();
                var model    = Mapper.Map <IEnumerable <Product>, List <ProductDTO> >(products);
                return(Ok(model));
            }
        }
 public void ComplexTypeTableValuedFunctionTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         IQueryable <ContactInformation> employees = adventureWorks.ufnGetContactInformation(1).Take(2);
         Assert.NotNull(employees.Single());
     }
 }
 public void EntityTypeTableValuedFunctionTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         IQueryable <Person> persons = adventureWorks.ufnGetPersons("a").Take(2);
         Assert.True(persons.Any());
     }
 }
Ejemplo n.º 19
0
        public void Invalid_add_relation_field_path()
        {
            var aw = new AdventureWorks();
            var path = new FieldPath(aw.Products["ProductCategoryID"]);

            // no link between relation field product.category and normal field contact.name
            Assert.Throws<ArgumentException>(() => { path.Add(aw.Contacts.DefaultField); });
        }
Ejemplo n.º 20
0
        public void Invalid_add_field_path()
        {
            var aw   = new AdventureWorks();
            var path = new FieldPath(aw.Products.DefaultField);

            // no link between normal field product.name and normal field contact.name
            Assert.Throws <InvalidOperationException>(() => { path.Add(aw.Contacts.DefaultField); });
        }
Ejemplo n.º 21
0
 public void StoredProcedureWithComplexTypeTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         ObjectResult <ManagerEmployee> employees = adventureWorks.GetManagerEmployees(2);
         EnumerableAssert.Any(employees);
     }
 }
Ejemplo n.º 22
0
        public void Invalid_add_relation_field_path()
        {
            var aw   = new AdventureWorks();
            var path = new FieldPath(aw.Products["ProductCategoryID"]);

            // no link between relation field product.category and normal field contact.name
            Assert.Throws <ArgumentException>(() => { path.Add(aw.Contacts.DefaultField); });
        }
Ejemplo n.º 23
0
        public void Single_field_path()
        {
            var aw   = new AdventureWorks();
            var path = new FieldPath(aw.Products.DefaultField);

            Assert.AreEqual(1, path.Count);
            Assert.AreEqual(aw.Products.DefaultField, path[0]);
        }
Ejemplo n.º 24
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         AdventureWorks.Dispose();
     }
     base.Dispose(disposing);
 }
 public void NonComposableScalarValuedFunctionTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         decimal?cost = adventureWorks.ufnGetProductStandardCost(999, DateTime.Now);
         Assert.NotNull(cost);
         Assert.True(cost > 1);
     }
 }
Ejemplo n.º 26
0
 public void StoreProcedureWithMultipleResultsTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
         using (IMultipleResults results = adventureWorks.uspGetCategoryAndSubcategory(1))
         {
             EnumerableAssert.Single(results.GetResult <ProductCategory>());
             EnumerableAssert.Any(results.GetResult <ProductSubcategory>());
         }
 }
Ejemplo n.º 27
0
        public void Insert0_field_path()
        {
            var aw = new AdventureWorks();
            var path = new FieldPath();

            // creating the path in reverse should be fine
            path.Insert(0, aw.ProductCategory.DefaultField);
            path.Insert(0, aw.Products["ProductCategoryID"]);
            path.Insert(0, aw.SalesOrderDetails["ProductID"]);
        }
Ejemplo n.º 28
0
        public void Insert0_field_path()
        {
            var aw   = new AdventureWorks();
            var path = new FieldPath();

            // creating the path in reverse should be fine
            path.Insert(0, aw.ProductCategory.DefaultField);
            path.Insert(0, aw.Products["ProductCategoryID"]);
            path.Insert(0, aw.SalesOrderDetails["ProductID"]);
        }
 public void ComposableScalarValuedFunctionLinqTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         IQueryable <Product> products = adventureWorks
                                         .Products
                                         .Where(product => product.ListPrice <= adventureWorks.ufnGetProductListPrice(999, DateTime.Now));
         Assert.True(products.Any());
     }
 }
Ejemplo n.º 30
0
 public void StoreProcedureWithOutParameterTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         int?errorLogId  = 5;
         int returnValue = adventureWorks.uspLogError(ref errorLogId);
         Assert.AreEqual(0, errorLogId.Value);
         Assert.AreEqual(0, returnValue);
     }
 }
Ejemplo n.º 31
0
        public void Single_subject_single_field()
        {
            var aw  = new AdventureWorks();
            var gen = new SqlGenerator(aw)
                      .Target(aw.Products)
                      .Column(new FieldPath(aw.Products.IdField));

            Test(gen, @"
SELECT     Production.Product.ProductID
FROM         Production.Product");
        }
Ejemplo n.º 32
0
        public void Invalid_remove_relation_field_path()
        {
            var aw = new AdventureWorks();
            var path = new FieldPath(
                aw.SalesOrderDetails["ProductID"],
                aw.Products["ProductCategoryID"],
                aw.ProductCategory.DefaultField);

            // removing the middle relation creates an invalid link between sales order.product -> category.name
            Assert.Throws<ArgumentException>(() => { path.Remove(aw.Products["ProductCategoryID"]); });
        }
Ejemplo n.º 33
0
 public void InheritanceTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         SalesTransactionHistory[] transactions = adventureWorks
                                                  .SalesTransactions
                                                  .Where(transaction => transaction.ActualCost > 0)
                                                  .ToArray();
         EnumerableAssert.Multiple(transactions);
     }
 }
Ejemplo n.º 34
0
        public void Clear_field_path()
        {
            var aw = new AdventureWorks();
            var path = new FieldPath(
                aw.SalesOrderDetails["ProductID"],
                aw.Products["ProductCategoryID"],
                aw.ProductCategory.DefaultField);

            path.Clear();
            Assert.AreEqual(0, path.Count);
        }
Ejemplo n.º 35
0
 public void GetInvokeMemberConvertFromTypeTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         IQueryable <Product> query =
             adventureWorks.Products.Where(product => product.ProductID > 0).OrderBy(p => p.Name).Take(2);
         IEnumerable <Product> results =
             adventureWorks.ToDynamic().Provider.Execute(query.Expression).ReturnValue;
         Assert.IsTrue(results.Any());
     }
 }
Ejemplo n.º 36
0
        public void FromDefault_field_path()
        {
            var aw = new AdventureWorks();
            aw.Products.DefaultField = aw.Products["ProductCategoryID"];

            var path = FieldPath.FromDefault(aw.Products.DefaultField);

            // should be product.category -> category.name
            Assert.AreEqual(2, path.Count);
            Assert.AreEqual(aw.Products["ProductCategoryID"], path[0]);
            Assert.AreEqual(aw.ProductCategory["Name"], path[1]);
        }
		/// <summary>General factory entrance method which will return an EntityFields2 object with the format generated by the factory specified</summary>
		/// <param name="relatedEntityType">The type of entity the fields are for</param>
		/// <returns>The IEntityFields instance requested</returns>
		public static IEntityFields2 CreateEntityFieldsObject(AdventureWorks.Dal.Adapter.v41.EntityType relatedEntityType)
		{
			return FieldInfoProviderSingleton.GetInstance().GetEntityFields(InheritanceInfoProviderSingleton.GetInstance(), _entityTypeNamesCache[relatedEntityType]);
		}
Ejemplo n.º 38
0
		/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary>
		/// <param name="leftOperand">The left operand.</param>
		/// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param>
		/// <param name="rightOperand">The right operand which is an entity type.</param>
		/// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
		/// <param name="onClause">The on clause for the join.</param>
		public DynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, AdventureWorks.Dal.Adapter.v42.EntityType rightOperand, string aliasRightOperand, IPredicate onClause)
		{
			this.InitClass(joinType, string.Empty, aliasRightOperand, onClause, leftOperand, GeneralEntityFactory.Create(rightOperand));
		}
Ejemplo n.º 39
0
		/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary>
		/// <param name="leftOperand">The left operand which is a field.</param>
		/// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param>
		/// <param name="rightOperand">The right operand which is an entity.</param>
		/// <param name="aliasLeftOperand">The alias of the left operand. If you don't want to / need to alias the left operand (only alias if you have to), specify string.Empty.</param>
		/// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
		/// <param name="onClause">The on clause for the join.</param>
		public DynamicRelation(IEntityFieldCore leftOperand, JoinHint joinType, AdventureWorks.Dal.Adapter.v42.EntityType rightOperand, string aliasLeftOperand, string aliasRightOperand, IPredicate onClause)
		{
			this.InitClass(joinType, aliasLeftOperand, aliasRightOperand, onClause, leftOperand, GeneralEntityFactory.Create(rightOperand));
		}
Ejemplo n.º 40
0
        public void Single_field_path()
        {
            var aw = new AdventureWorks();
            var path = new FieldPath(aw.Products.DefaultField);

            Assert.AreEqual(1, path.Count);
            Assert.AreEqual(aw.Products.DefaultField, path[0]);
        }
Ejemplo n.º 41
0
        public void Multiple_field_path()
        {
            var aw = new AdventureWorks();
            var path = new FieldPath(
                aw.SalesOrderDetails["ProductID"],
                aw.Products["ProductCategoryID"],
                aw.ProductCategory.DefaultField);

            Assert.AreEqual(3, path.Count);
            Assert.AreEqual(aw.SalesOrderDetails["ProductID"], path[0]);
            Assert.AreEqual(aw.Products["ProductCategoryID"], path[1]);
            Assert.AreEqual(aw.ProductCategory.DefaultField, path[2]);
        }
 public virtual int Fill(AdventureWorks.TopStoreDataTable dataTable) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     AdventureWorks ds = new AdventureWorks();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "TopModelDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     AdventureWorks ds = new AdventureWorks();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
 public virtual int Fill(AdventureWorks.TopModelDataTable dataTable, int CustomerID) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     this.Adapter.SelectCommand.Parameters[0].Value = ((int)(CustomerID));
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }