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
bani marc
NA
54
2.5k
Cast var linq query in int issue
Oct 18 2017 12:11 PM
Hi everybody, I'm trying to build a chart in asp.net. For that I'm trying to cast the result of my linq query in int type but I have an error saying that only int, string, decimal type can be use. I don't understant what happened. Is someone have an idea ?? Here is my code :
protected
void
GetChartData2()
{
Series series = Chart2.Series[
"Series2"
];
series.Color = System.Drawing.Color.Blue;
using
(Context db =
new
Context())
{
if
(db.InfoLivraison.Count() > 0)
{
DateTime end = Convert.ToDateTime(DateTime.Now.ToString(
"dd/MM/yyyy"
));
DateTime start = end.AddDays(-7);
List<InfoLivraison> listCA = (from infoLivCA
in
db.InfoLivraison
where infoLivCA.date_command2 >= start && infoLivCA.date_command2 <= end
select infoLivCA).ToList();
DataTable dt2 = ToDataTable<InfoLivraison>(listCA);
DataTable dtjour = dt2.DefaultView.ToTable(
"Jours7CA"
,
true
,
"date_command2"
);
DataTable dtMontant = dt2.DefaultView.ToTable(
"Montants7CA"
,
true
,
"montantCommande"
);
if
(dtjour.Rows.Count != 0)
{
for
(
int
i = 0; i < dtjour.Rows.Count; i++)
{
DateTime selectedDate = Convert.ToDateTime(dtjour.Rows[i][
"date_command2"
]);
string
selectedDateStr = Convert.ToString(selectedDate);
for
(
int
j=0;j<dtjour.Rows.Count;j++)
{
var linqSum = db.InfoLivraison.GroupBy(a => selectedDate)
.Select(b =>
new
{ total = b.Sum(a => Convert.ToDecimal(a.montantCommande))});
series.Points.AddXY(selectedDate.ToString(
"dd/MM/yyyy"
), linqSum);
}
}
}
}
}
}
Thanks for your help
Reply
Answers (
1
)
Unit Testing in ASP.NET Web forms
email verification code live.but error coming.