本文整理汇总了C#中IQueryable.Include方法的典型用法代码示例。如果您正苦于以下问题:C# IQueryable.Include方法的具体用法?C# IQueryable.Include怎么用?C# IQueryable.Include使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQueryable
的用法示例。
在下文中一共展示了IQueryable.Include方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetQuery
public IQueryable<Department> GetQuery(IQueryable<Department> query)
{
foreach (var p in IncludePaths)
{
query = query.Include(p);
}
return query;
}
示例2: ModifyQuery
public override IQueryable ModifyQuery(IQueryable query)
{
foreach (var child in this.ChildNodes)
{
var parameter = Expression.Parameter(this.inputType, "o");
var childExpression = child.BuildLinqExpression(query, query.Expression, parameter);
var member = childExpression as MemberExpression;
query = query.Include(member.Member.Name);
}
return query;
}
示例3: ModifyQuery
public override IQueryable ModifyQuery(IQueryable query)
{
foreach (var child in this.ChildNodes)
{
var parameter = Expression.Parameter(this.inputType, "o");
var childExpression = child.BuildLinqExpression(query, query.Expression, parameter);
this.VisitMember(childExpression as MemberExpression);
if (this.members.Count() > 0)
{
query = query.Include(string.Join(".", this.members));
this.members.Clear();
}
}
return query;
}
示例4: Get
internal static IEnumerable<User> Get(IQueryable<UserEntity> query)
{
return (from u in query.Include(q => q.Roles).Include(q => q.Places).ToList()
select new User
{
Id = u.Id,
Name = u.Name,
FirstName = u.FirstName,
LastName = u.LastName,
UserName = u.UserName,
Email = u.Email,
Birthday = u.Birthday,
Created = u.Created,
LastLogin = u.LastLogin,
Token = u.Token,
Roles = u.Roles.Select(r => r.Role).ToList(),
PlaceRoles = u.Places.Select(r => new Tuple<int, string>(r.PlaceId, r.Role)).ToList(),
}).ToList();
}
示例5: EntriesQueryToDetailsAsync
private static async Task<IList<TimelineEntryDetails>> EntriesQueryToDetailsAsync(
IQueryable<TimelineEntry> q)
{
var results = await q
.Include(te => te.User.Avatar)
.Include(te => te.Message.Likes.Select(like => like.User))
.Include(te => te.CommentThread.Comments.Select(c => c.Text))
.Include(te => te.CommentThread.Comments.Select(c => c.User.Avatar))
.Select(
te =>
new
{
te.TimelineEntryId,
User = te.User,
Message = te.Message.Content,
DateTime = te.Message.CreatedUtc,
Media = te.Media.Select(tme => tme.Media),
Likes = te.Message.Likes,
te.CommentThread
})
.ToListAsync();
return results.Select(
te =>
new TimelineEntryDetails
{
UserId = te.User.UserInfoId,
UserName = te.User.Name,
AvatarUrl = UserOperations.GetAvatarUrl(te.User),
Message = te.Message,
DateTime = te.DateTime.ToString("s"),
MediaUrls = te.Media.Select(UserMediaOperations.GetUrl).ToList(),
LikeUrl = $"/api/Timeline/{te.TimelineEntryId}/Like",
LikeGroups = LikeOperations.MakeLikeGroups(te.Likes),
CommentUrl = $"/api/Timeline/{te.TimelineEntryId}/Comment",
Comments = CommentOperations.GetComments(te.CommentThread)
})
.ToList();
}
示例6: IncludeAdditionalDataForGroups
private IQueryable<Group> IncludeAdditionalDataForGroups(bool withOwner, bool withUsers, bool withTasks, IQueryable<Group> groups)
{
if (withOwner)
{
groups = groups.Include(x => x.Owner);
}
if (withUsers)
{
groups = groups.Include(x => x.Users);
}
if (withTasks)
{
groups = groups.Include(x => x.Tasks);
}
return groups;
}
示例7: Get
internal static IEnumerable<Place> Get(IQueryable<PlaceEntity> query)
{
return (from r in query.Include(i => i.Services).Include(i => i.Location).Include("Location.Region").Include(i => i.Files).ToList()
select new Place
{
Id = r.Id,
Description = r.Name,
Info = r.Description,
Address = r.Address,
Location = r.LocationId != null ? new Location
{
Id = (int)r.LocationId,
Description = r.Location.Description,
IsActive = r.IsActive,
Region = r.Location.Region.ToEntity<Region>(),
} : null,
MapLocation = r.MapLocation,
MapUa = r.MapUa,
MapVa = r.MapVa,
Phone = r.Phone,
HowToArrive = r.HowToArrive,
Services = r.Services.Select(s => (Service)s.Service),
Images = r.Files.Select(f => new File
{
Id = f.Id,
ContentLength = f.ContentLength,
ContentType = f.ContentType,
Description = f.Description,
FileName = f.FileName,
CreatedBy = new User { Id = f.UserId, },
InsertDate = f.InsertDate,
}),
DateFrom = r.DateFrom,
Page = r.Page,
IsActive = r.IsActive,
Courts = r.Courts.Count(),
}).ToList();
}
示例8: QueryBoards
private async Task<BoardList> QueryBoards(IQueryable<IBoard> table, string currentUser)
{
var profile = await db.ClientUsers.FirstOrDefaultAsync(p => p.Username == currentUser);
var exist = await table.FirstOrDefaultAsync(p => p.ClientUserId == profile.Id);
//2
var level1Left = (profile == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == profile.Id && p.Position == Position.Left);
var level1Right = (profile == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == profile.Id && p.Position == Position.Right);
//4
var level2Left1 = (level1Left == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level1Left.ClientUserId && p.Position == Position.Left);
var level2Right1 = (level1Left == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level1Left.ClientUserId && p.Position == Position.Right);
var level2Left2 = (level1Right == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level1Right.ClientUserId && p.Position == Position.Left);
var level2Right2 = (level1Right == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level1Right.ClientUserId && p.Position == Position.Right);
//8
var level3Left1 = (level2Left1 == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level2Left1.ClientUserId && p.Position == Position.Left);
var level3Right1 = (level2Left1 == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level2Left1.ClientUserId && p.Position == Position.Right);
var level3Left2 = (level2Right1 == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level2Right1.ClientUserId && p.Position == Position.Left);
var level3Right2 = (level2Right1 == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level2Right1.ClientUserId && p.Position == Position.Right);
var level3Left3 = (level2Left2 == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level2Left2.ClientUserId && p.Position == Position.Left);
var level3Right3 = (level2Left2 == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level2Left2.ClientUserId && p.Position == Position.Right);
var level3Left4 = (level2Right2 == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level2Right2.ClientUserId && p.Position == Position.Left);
var level3Right4 = (level2Right2 == null) ? null : table.Include(p => p.ClientUser).FirstOrDefault(p => p.UplineUserId == level2Right2.ClientUserId && p.Position == Position.Right);
return new BoardList()
{
Profile = exist,
Level1Left = level1Left,
Level1Right = level1Right,
Level2Left1 = level2Left1,
Level2Left2 = level2Left2,
Level2Right1 = level2Right1,
Level2Right2 = level2Right2,
Level3Left1 = level3Left1,
Level3Left2 = level3Left2,
Level3Left3 = level3Left3,
Level3Left4 = level3Left4,
Level3Right1 = level3Right1,
Level3Right2 = level3Right2,
Level3Right3 = level3Right3,
Level3Right4 = level3Right4
};
}
示例9: SearchWithDetails
/// <summary>
/// Searches the with details.
/// </summary>
/// <param name="reversed">if set to <c>true</c> [reversed].</param>
/// <param name="sortedPersonQry">The sorted person qry.</param>
/// <param name="rockContext">The rock context.</param>
/// <returns></returns>
private List<PersonSearchResult> SearchWithDetails( IQueryable<Person> sortedPersonQry, bool showFullNameReversed )
{
var rockContext = this.Service.Context as Rock.Data.RockContext;
var phoneNumbersQry = new PhoneNumberService( rockContext ).Queryable();
var sortedPersonList = sortedPersonQry.Include( a => a.PhoneNumbers ).AsNoTracking().ToList();
Guid activeRecord = new Guid( SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE );
List<PersonSearchResult> searchResult = new List<PersonSearchResult>();
foreach ( var person in sortedPersonList )
{
PersonSearchResult personSearchResult = new PersonSearchResult();
personSearchResult.Id = person.Id;
personSearchResult.Name = showFullNameReversed ? person.FullNameReversed : person.FullName;
if ( person.RecordStatusValueId.HasValue )
{
var recordStatus = DefinedValueCache.Read( person.RecordStatusValueId.Value );
personSearchResult.RecordStatus = recordStatus.Value;
personSearchResult.IsActive = recordStatus.Guid.Equals( activeRecord );
}
else
{
personSearchResult.RecordStatus = string.Empty;
personSearchResult.IsActive = false;
}
GetPersonSearchDetails( personSearchResult, person );
searchResult.Add( personSearchResult );
}
return searchResult;
}
示例10: Get
internal static List<CommentDto> Get(IQueryable<Comment> query)
{
var list = query.Include(p => p.Place).Include(p => p.User).ToList();
return CommentBusiness.GetList(list.Where(i => i.ReplyCommentID == null).ToList(), list.Where(i => i.ReplyCommentID != null).ToList());
}
示例11: Get
internal static IEnumerable<CourtBook> Get(IQueryable<CourtBookEntity> query)
{
return (from r in (query is ObjectQuery<CourtBookEntity> ? query.Include(q => q.Client).Include(q => q.Court) : query).ToList()
select new CourtBook
{
Id = r.Id,
Court = Court.Create<Court>(r.CourtId, r.Court.Name, r.Court.IsActive),
StartTime = r.StartTime,
EndTime = r.EndTime,
Price = r.Price,
ReserveRequired = r.ReserveRequired,
Reserve = r.Reserve,
Paid = r.Paid,
Client = r.Client != null ? new Client { Id = r.ClientId, Description = r.Client.Name, Phone = r.Client.Phone, Place = Place.Create<Place>(r.Client.PlaceId), IsActive = r.Client.IsActive, } : null,
Comment = r.Comment,
User = r.UserId,
}).ToList();
}