当前位置: 首页>>代码示例>>C#>>正文


C# IProductRepository.GetAll方法代码示例

本文整理汇总了C#中IProductRepository.GetAll方法的典型用法代码示例。如果您正苦于以下问题:C# IProductRepository.GetAll方法的具体用法?C# IProductRepository.GetAll怎么用?C# IProductRepository.GetAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProductRepository的用法示例。


在下文中一共展示了IProductRepository.GetAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProductsLookupViewModel

 public ProductsLookupViewModel(IProductRepository productRepository)
 {
     Products = (List<Product>) productRepository.GetAll();
     _productsView = CollectionViewSource.GetDefaultView(_products);
     _productsView.CurrentChanged += ProductsViewCurrentChanged;
 }
开发者ID:JohnCai,项目名称:LonggongMM,代码行数:6,代码来源:ProductsLookupViewModel.cs

示例2: Main

        static void Main(string[] args)
        {
            IKernel kernel = new StandardKernel();

            kernel.Bind<IShipperRepository>().To<Data.ShipperRepository>().WithConstructorArgument("connectionString", "DataSource=xxx");
            kernel.Bind<ICategoryRepository>().To<Data.CategoryRepository>();
            kernel.Bind<IProductRepository>().To<Data.ProductRepository>();

            //are these needed???
            /*
            kernel.Bind<IShipper>().To<Entities.Shipper>();
            kernel.Bind<ICategory>().To<Entities.Category>();    
            kernel.Bind<IProduct>().To<Entities.Product>();    
            */

            shipperRepository = kernel.Get<IShipperRepository>();
            categoryRepository = kernel.Get<ICategoryRepository>();
            productRepository = kernel.Get<IProductRepository>();
            
            System.Console.WriteLine("Connection String: {0}", shipperRepository.ToString());

            #region MAPS STUFF
            /*
            // SIMPLE QUERY
            foreach(var item in organisationRepository.GetAllOrganisations())
            {
                System.Console.WriteLine("OrgId: {0} ¦ OrgName: {1} ¦ Phone: {2}", item.OrganisationId, item.OrganisationName, item.Phone);
            }         

            // SIMPLE JOIN QUERY WITH PARAMETER
            foreach (var item in organisationRepository.GetAllOrganisationsInGroupId(474))
            {
                System.Console.WriteLine("OrgId: {0} ¦ OrgName: {1} ¦ Phone: {2}", item.OrganisationId, item.OrganisationName, item.Phone);
            }

            // SIMPLE QUERY USING EMBEDDED SQL RESOURCE
            foreach (var item in personRepository.GetAllPeople())
            {
                System.Console.WriteLine("PersonId: {0} ¦ LastName: {1} ¦ FirstName: {2} ¦ Phone: {3}", item.PersonId, item.LastName, item.FirstName, item.MobilePhone);
            }

            // SIMPLE QUERY USING STORED PROC
            foreach (var item in titleRepository.GetAllTitles())
            {
                System.Console.WriteLine("TitleId: {0} ¦ Desc: {1}", item.TitleID, item.TitleDesc);
            }

            // MULTIPLE QUERIES RESULTS
            var org = organisationRepository.GetOrganisationWithGroups(448);
            if (org != null)
            {
                System.Console.WriteLine("OrgId: {0} ¦ OrgName: {1} ¦ Phone: {2}", org.OrganisationId, org.OrganisationName, org.Phone);
                foreach (var grp in org.Groups)
                {
                    System.Console.WriteLine("GroupId: {0} ¦ Desc: {1}", grp.GroupID, grp.GroupDesc);
                }
            }

            // MULTI MAPPING QUERY WITH PARAMETER (a single row to multiple objects)
            var person = personRepository.GetPersonWithOrganisation(3348);
            if (person != null)
            {
                System.Console.WriteLine("PersonId: {0} ¦ LastName: {1} ¦ FirstName: {2}", person.PersonId, person.LastName, person.FirstName);
            }

            // INSERT ITEM QUERY
            MyDapperDemo.Entities.MAPS.Organisation newOrg = new Entities.MAPS.Organisation
            {
                OrganisationName = "Barrys Bits",
                Phone = "555 551155"
            };
            int rowsAffected = organisationRepository.AddOrganisation2(newOrg);
            System.Console.WriteLine("Rows affected: {0}", rowsAffected);
            System.Console.WriteLine("NewId: {0}", org.OrganisationId);

            foreach (var item in organisationRepository.GetAllOrganisations())
            {
                System.Console.WriteLine("OrgId: {0} ¦ OrgName: {1} ¦ Phone: {2}", item.OrganisationId, item.OrganisationName, item.Phone);
            }

            // QUERY WITH DYNAMIC RESULT
            dynamic bankaccs = organisationRepository.GetAllBankAccounts();
            foreach (var item in bankaccs)
            {
                System.Console.WriteLine("AccName: {0}", item.BankAccountName);
            }

            
            */

            /*

            MyDapperDemo.Entities.MAPS.Person p = new Entities.MAPS.Person
            {
                FirstName = "Hoof",
                LastName = "Hearted",
                MobilePhone = "021 5553332",
                DirectEmail = "[email protected]"
            };

//.........这里部分代码省略.........
开发者ID:BarryBurke,项目名称:MyDapperDemo,代码行数:101,代码来源:Program.cs

示例3: XmlFileNotExists_TryGetAll_ShouldReturnEmptyList

        public void XmlFileNotExists_TryGetAll_ShouldReturnEmptyList()
        {
            _configurationWrapperMock
                .Setup(x => x.GetSettingValue<string>("XMLDataProductsFilePath"))
                .Returns(@"C:\Test\NotExistingFile.xml");

            _productRepository = new ProductXMLRepository(_configurationWrapperMock.Object, _xmlWrapper);

            var result = _productRepository.GetAll();

            Assert.That(result, Is.Empty);
        }
开发者ID:gabrielfbarros,项目名称:supply-manager-product-microservice,代码行数:12,代码来源:ProductXMLRepositoryTest.cs


注:本文中的IProductRepository.GetAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。