Skip to content

Instantly share code, notes, and snippets.

@moaschterle
Created May 13, 2015 12:09
Show Gist options
  • Save moaschterle/13baf47018b7197d55e7 to your computer and use it in GitHub Desktop.
Save moaschterle/13baf47018b7197d55e7 to your computer and use it in GitHub Desktop.
//also des isch der Index
public class EventMegaFilter : AbstractIndexCreationTask<Event>
{
/// <summary>
/// Filter ACtivities and POIs by
/// SMGActive, Type, Subtype, Region, TV, SMG Tags
/// </summary>
public EventMegaFilter()
{
Map = events => from info in events
select new EventIndexed
{
Active = info.Active,
SmgActive = info.SmgActive,
Type = info.Type,
Ranc = info.Ranc,
OrgRID = info.OrgRID,
DistrictId = info.DistrictId,
DistrictIds = info.DistrictIds,
SmgTags = info.SmgTags,
TopicRIDs = info.TopicRIDs,
DateBegin = info.DateBegin,
DateEnd = info.DateEnd,
RegionId = info.LocationInfo.RegionInfo.Id,
MunicipalityId = info.LocationInfo.MunicipalityInfo.Id,
TourismvereinId = info.LocationInfo.TvInfo.Id
};
}
}
public class EventIndexed : Event
{
public string RegionId { get; set; }
public string MunicipalityId { get; set; }
public string TourismvereinId { get; set; }
}
}
//Query muassi nor so mochen
var activityliste = await RavenSession.Query<EventIndexed, EventMegaFilter>()
//.UsingDefaultOperator(QueryOperator.And)
.Statistics(out queryStatistics)
.CustomizeIf(myseed != "null", x => x.RandomOrdering(myseed))
.WhereIf(topicrids.Count > 0, x => x.TopicRIDs.In(topicrids))
.WhereIf(idlist.Count > 0, x => x.Id.In(idlist))
//District Municipality Region
.WhereIf(districtlist.Count > 0, x => x.DistrictId.In(districtlist))
.WhereIf(tourismvereinlist.Count > 0, x => x.TourismvereinId.In(tourismvereinlist))
.WhereIf(municipalitylist.Count > 0, x => x.MunicipalityId.In(municipalitylist))
.WhereIf(regionlist.Count > 0, x => x.RegionId.In(regionlist))
.WhereIf(mysmgtaglist.Count > 0, x => x.SmgTags.In(mysmgtaglist))
.WhereIf(orgidlist.Count > 0, x => x.OrgRID.In(orgidlist))
.WhereIf(rancidlist.Count > 0, x => x.Ranc.ToString().In(rancidlist))
.WhereIf(typeidlist.Count > 0, x => x.Type.In(typeidlist))
.Skip(pageskip)
.Take(pagesize)
.ProjectFromIndexFieldsInto<Event>()
.ToListAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment