Reputation: 3627
How to tell the First method which is part of LINQ library to return proper value. I have something like this:
var query = db.SinglePageContent.Where(q => q.Lang == zm1 && q.PageName == zm2).Select(s => new { s.Content});
//var reqUrl = query.FirstOrDefault(item => item.Content);
ViewBag.requestUrl = query.First();
and now the ViewBag.requestUrl
has value { Content = bla bla bla }
, but I want to have only "bla bla bla". I just don't know how to get there to only retrieve value. Any ideas?
Upvotes: 1
Views: 114
Reputation: 1851
You are creating new anonymous class with new { }
use this instead
var query = db.SinglePageContent.Where(q => q.Lang == zm1 && q.PageName == zm2)
.Select(s => s.Content);
Upvotes: 8