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


C# DatabaseContext.Select方法代码示例

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


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

示例1: Get

        public List<MechanicJob> Get(int itemsPerPage, int currentPage)
        {
            var entities = new DatabaseContext().MechanicJobs
                .Include("Car")
                .Include("Car.CarModel")
                .Include("Car.CarType")
                .Include("MechanicType")
                .OrderBy(o => o.Id)
                .Skip(itemsPerPage * (currentPage - 1))
                .Take(itemsPerPage)
                .ToList();

            var mechanicJobs = entities.Select(s => new MechanicJob
            {
                Id = s.Id,
                Price = s.Price,
                Car = new Car
                {
                    Id = s.Car.Id,
                    CarNumber = s.Car.CarNumber,
                    CarType = new CarType { Id = s.Car.CarType.Id, ArabicName = s.Car.CarType.ArabicName },
                    CarModel = new CarModel { Id = s.Car.CarModel.Id, ArabicName = s.Car.CarModel.ArabicName },
                },
                MechanicType = s.MechanicType,
            })
            .ToList();

            return mechanicJobs;
        }
开发者ID:Mohamed-Ahmed-Abdullah,项目名称:CarWorkshop,代码行数:29,代码来源:ApiMechanicJobController.cs

示例2: Find

        public ContentItem Find(long id, int depth)
        {
            List<ContentItem> contentItems = null;

            using (DatabaseContext context = new DatabaseContext())
            {
                string query = "DECLARE @parent hierarchyId = (SELECT TOP 1 Node FROM [dbo].[ContentItem] WHERE Id = @id);";
                query += "SELECT * FROM [dbo].[ContentItem] WHERE Node = @parent ";

                for (int i = 1; i <= depth; i++)
                {
                    query += " OR Node.GetAncestor(" + i + ") = @parent";
                }

                contentItems = context.Select<MSSQL.Entities.ContentItem, ContentItem>(query, new { id = id, }).ToList();
            }

            if (contentItems != null && contentItems.Any())
            {
                ContentItem parentContentItem = contentItems.Single(contentItem => contentItem.Id == id);
                contentItems.Remove(parentContentItem);
                return ContentItemsToTree(parentContentItem, contentItems);
            }

            return null;
        }
开发者ID:orelinde,项目名称:CZCI,代码行数:26,代码来源:ContentItemDao.cs

示例3: FindAllPublicTimelines

 public IEnumerable<Timeline> FindAllPublicTimelines()
 {
     using (DatabaseContext context = new DatabaseContext())
     {
         string query = "SELECT [Timeline].[Id],BackgroundUrl,[RootContentItemId],[IsPublic],[BeginDate],[EndDate],[Title],[Description],[Timeline].[Timestamp] FROM [dbo].[Timeline] JOIN [dbo].[ContentItem] ON [dbo].[Timeline].[RootContentItemId] = [dbo].[ContentItem].[Id] where IsPublic=1";
         return context.Select<MSSQL.Entities.TimelineJoinContentItem, Timeline>(query);
     }
 }
开发者ID:orelinde,项目名称:CZCI,代码行数:8,代码来源:TimelineDao.cs

示例4: SelectWithCondition

        public void SelectWithCondition()
        {
            var context = new DatabaseContext(_provider.Object, _settings.Object);

            // Act
            var items = context.Select<string>(s => s == "condition");

            Assert.IsNotNull(items);
            _provider.Verify(p => p.Execute(It.IsAny<string>()), Times.Once);
        }
开发者ID:chriswalpen,项目名称:PersistenceMap,代码行数:10,代码来源:DatabaseContextTests.cs


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