Returning objects with null values for properties

44 views
Skip to first unread message

Neil Barnwell

unread,
Nov 8, 2011, 11:56:26 AM11/8/11
to rav...@googlegroups.com

I'm using Raven in ASP.NET MVC as follows:

[HttpGet]
public ActionResult Index()
{
   
ViewBag.Title = Strings.Workflows;
   
ViewBag.AddNewText = Strings.Add_new;

   
IEnumerable<WorkflowIndexViewModel> model;
    using
(var session = DocumentStore.OpenSession())
   
{
        model
= session.Query<Workflow>()
           
.Select(w => new WorkflowIndexViewModel { WorkflowId = w.Id, WorkflowName = w.Name })
           
.ToArray();
   
}

   
return View(model);
}

The weird thing is that the model object has one value in (as I'd expect because I know I have oneWorkflow document in my database), but both WorkflowId and WorkfloName properties on it arenull. Why is this? Is there a problem with my projection?

I have tried moving the ToArray() call to before the Select(), and that works just fine:

[HttpGet]
public ActionResult Index()
{
   
ViewBag.Title = Strings.Workflows;
   
ViewBag.AddNewText = Strings.Add_new;

   
IEnumerable<WorkflowIndexViewModel> model;
    using
(var session = DocumentStore.OpenSession())
   
{
        model
= session.Query<Workflow>()
           
.ToArray()
           
.Select(w => new WorkflowIndexViewModel { WorkflowId = w.Id, WorkflowName = w.Name });
   
}

   
return View(model);
}

Itamar Syn-Hershko

unread,
Nov 8, 2011, 12:09:20 PM11/8/11
to rav...@googlegroups.com
We fixed this in recent builds, can you try them (grab the latest unstable)?

Neil Barnwell

unread,
Nov 8, 2011, 1:06:26 PM11/8/11
to rav...@googlegroups.com
Ahh okay. I'm using build 1.0.499 from nuget, so I'll stick with that for now. Any idea when that fix will be in nuget?

Oren Eini (Ayende Rahien)

unread,
Nov 8, 2011, 1:10:23 PM11/8/11
to rav...@googlegroups.com
Probably the 21th
Reply all
Reply to author
Forward
0 new messages