TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
محمد صلاح الدين
NA
75
3.7k
Data collection between ages in mvc5
Dec 6 2018 10:51 AM
hi guys I have tried to collect data between ages but there is an error I do not know why here is my code my controller
public
ActionResult AllCuont()
{ var query = (from t
in
db.Pations
let range = ( t.Age >= 0 && t.Age < 10 ?
"0-9"
:
t.Age >= 11 && t.Age < 15 ?
"10-14"
:
t.Age >= 15 && t.Age < 50 ?
"15-50"
:
"50+"
)
group t by range into g
select
new
UserRange { AgeRange = g.Key, Count = g.Count() }).ToList();
//add the sum column.
query.Add(
new
UserRange() { AgeRange =
"Sum"
, Count = query.Sum(c => c.Count) }); ViewBag.UserData = query;
return
View(); }
and this is my model for To collect value
namespace
Archive.Models
{
public
class
UserRange {
public
string
AgeRange {
get
;
set
; }
public
IEnumerable<Pation> Count {
get
;
set
; } }
}
i Can't find the problem can you help me
the problem in my controller here
Reply
Answers (
1
)
Content placeholder
How to put hyperlink in conditional statement.