How to filter record from a model into RavenDB using C#?

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 244
Let's say we have a model as under

public class RSS
{
public string Id { get; set; }
public string QuestionID { get; set; }
public string QuestionTitle { get; set; }
public string QuestionDescription { get; set; }
public DateTime PublishDate { get; set; }
}


The below piece of code will filter data

public List<RSS> ReadRssFeed(IEnumerable<string> lstIDs)
{
var rssCollection = new List<RSS>();
using (var ds = new DocumentStore
{
Url = "http://localhost:8080",
DefaultDatabase = "CRUDDemo"
}.Initialize())
using (var session = ds.OpenSession())
{
//Find records whose question title starts with "NAudio"
session
.Query<RSS>()
.Where(rss=>rss.QuestionTitle.StartsWith("NAudio"))
.ToList()
.ForEach((e) => rssCollection.Add(e));
}
return rssCollection;
}

Comments or Responses

Login to post response