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

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 203
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 read all data from from RSS model to RavenDB

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())
{
foreach (var id in lstIDs)
{
rssCollection.Add(session.Load<RSS>(id));
}
}
return rssCollection;
}

Comments or Responses

Login to post response