I create a BLL class and write the below code, then assign it through a ObjectDataSource to a gridview as a DataSource, but after press F5, does not show anything.
please help me!
public IQueryable AcceptedPaper()
{
var query = from p in db.Papers
from s in p.PaperStatuses
from a in p.Authors
where s.PaperStatus == "Rejected" && a.IsFirstAuthor==true
select new
{
Title=p.PaperTitle,
FirstAuthor=a.AuthorLastName,
Status=s.PaperStatus
};
return query.Distinct();
}
You need one model class for example NewPaperStatus, and change your code accordingly like this:
public class RepoClass
{
public IQueryable<NewPaperStatus> AcceptedPaper()
{
var query = (from p in db.Papers
from s in p.PaperStatuses
from a in p.Authors
where s.PaperStatus == "Rejected" && a.IsFirstAuthor == true
select new
{
Title = p.PaperTitle,
FirstAuthor = a.AuthorLastName,
Status = s.PaperStatus
}).Distinct();
return query;
}
}
public class NewPaperStatus
{
public string PaperTitle { get; set; }
public string AuthorLastName { get; set; }
public string PaperStatus { get; set; }
}
Lotfinejad
Member
20 Points
13 Posts
Select Multiple object in LINQ Query
Jun 03, 2012 10:12 PM|LINK
I create a BLL class and write the below code, then assign it through a ObjectDataSource to a gridview as a DataSource, but after press F5, does not show anything.
please help me!
public IQueryable AcceptedPaper() { var query = from p in db.Papers from s in p.PaperStatuses from a in p.Authors where s.PaperStatus == "Rejected" && a.IsFirstAuthor==true select new { Title=p.PaperTitle, FirstAuthor=a.AuthorLastName, Status=s.PaperStatus }; return query.Distinct(); }Linq asp
jsiahaan
Contributor
2304 Points
586 Posts
Re: Select Multiple object in LINQ Query
Jun 03, 2012 10:56 PM|LINK
Hi,
You need one model class for example NewPaperStatus, and change your code accordingly like this:
public class RepoClass { public IQueryable<NewPaperStatus> AcceptedPaper() { var query = (from p in db.Papers from s in p.PaperStatuses from a in p.Authors where s.PaperStatus == "Rejected" && a.IsFirstAuthor == true select new { Title = p.PaperTitle, FirstAuthor = a.AuthorLastName, Status = s.PaperStatus }).Distinct(); return query; } } public class NewPaperStatus { public string PaperTitle { get; set; } public string AuthorLastName { get; set; } public string PaperStatus { get; set; } }Hope this can help
Indonesian Humanitarian Foundation