本文整理汇总了C#中IQueryable.AsQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# IQueryable.AsQueryable方法的具体用法?C# IQueryable.AsQueryable怎么用?C# IQueryable.AsQueryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQueryable
的用法示例。
在下文中一共展示了IQueryable.AsQueryable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MemberList
public IEnumerable<DirectoryInfo> MemberList()
{
members = FetchMembers();
if (!count.HasValue)
count = Count();
var q1 = members.AsQueryable();
if (Sort == "Birthday")
q1 = from p in q1
orderby DbUtil.Db.NextBirthday(p.PeopleId)
select p;
else
{
var qf = (from p in members
let famname = p.Family.People.Single(hh => hh.PeopleId == hh.Family.HeadOfHouseholdId).Name2
group p by new {famname, p.FamilyId}
into g
orderby g.Key.famname, g.Key.FamilyId
select g.Max(pp => pp.FamilyId)).Skip(StartRow).Take(PageSize);
;
q1 = from p in q1
where qf.Contains(p.FamilyId)
let pos = (p.PositionInFamilyId == 10 ? p.GenderId : 1000 - (p.Age ?? 0))
let famname = p.Family.People.Single(hh => hh.PeopleId == hh.Family.HeadOfHouseholdId).Name2
orderby famname, p.FamilyId, p.PositionInFamilyId == 10 ? p.GenderId : 1000 - (p.Age ?? 0)
select p;
}
var q2 = from p in q1
select new DirectoryInfo
{
Family = p.LastName,
FamilyId = p.FamilyId,
Name = p.PreferredName,
Suffix = p.SuffixCode,
Birthday = p.BirthDate.ToString2("m"),
Address = p.PrimaryAddress,
Address2 = p.PrimaryAddress2,
CityStateZip = p.CityStateZip,
Cell = p.CellPhone.FmtFone("C"),
Home = p.HomePhone.FmtFone("H"),
Email = (p.SendEmailAddress1 ?? true) ? p.EmailAddress : "",
Email2 = (p.SendEmailAddress2 ?? false) ? p.EmailAddress2 : "",
DoNotPublishPhones = p.DoNotPublishPhones
};
return q2;
}
示例2: EstablishContext
protected override void EstablishContext()
{
studentIndicatorRepository = mocks.StrictMock<IRepository<StudentIndicator>>();
studentSchoolInformationRepository = mocks.StrictMock<IRepository<StudentSchoolInformation>>();
idNameService = mocks.StrictMock<Resources.School.IIdNameService>();
suppliedData = ReturnSuppliedData();
Expect.Call(studentIndicatorRepository.GetAll()).Return(suppliedData.AsQueryable());
Expect.Call(studentSchoolInformationRepository.GetAll()).Return(GetSuppliedStudentSchoolInformation());
Expect.Call(idNameService.Get(null))
.Constraints(new ActionConstraint<Resources.School.IdNameRequest>(x => Assert.That(x.SchoolId, Is.EqualTo(schoolId0))))
.Return(GetSuppliedSchoolIdNameModel());
}
示例3: Filter
public IQueryable<Contract> Filter(IQueryable<Contract> items, IEnumerable<ColumnFilterInfo> filterCriteria)
{
if (filterCriteria == null)
{
return items;
}
var result = items.AsQueryable();
foreach (var filterCriterion in filterCriteria)
{
result = this.headFilter.Filter(filterCriterion, result);
}
return result;
}
示例4: SetRecipients
private void SetRecipients( Panel pnl, HtmlAnchor htmlAnchor, Literal literalControl,
Grid grid, IQueryable<CommunicationRecipient> qryRecipients )
{
pnl.CssClass = pnlOpened.Visible ? "col-md-2-10 margin-b-md" : "col-md-3 margin-b-md";
int count = qryRecipients.Count();
if ( count <= 0 )
{
htmlAnchor.Attributes["disabled"] = "disabled";
}
else
{
htmlAnchor.Attributes.Remove( "disabled" );
}
literalControl.Text = count.ToString( "N0" );
var sortProperty = grid.SortProperty;
if ( sortProperty != null )
{
qryRecipients = qryRecipients.AsQueryable().Sort( sortProperty );
}
else
{
qryRecipients = qryRecipients.OrderBy( r => r.PersonAlias.Person.LastName ).ThenBy( r => r.PersonAlias.Person.NickName );
}
grid.SetLinqDataSource( qryRecipients );
grid.DataBind();
}