本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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);
}