I am using below two tables Registration and Application to get above counts report base on Dates, from 1 Sept 2018 to till and grid should be date descending order as above output my report. New Registration means on that day how registration came, cumulative
registrations means sum of registration counts on that particular day. And Application concept as same as registration.
According to your description,I have some question:
where is the second item from?
mazhar khan india
New Registration means on that day how registration came,
Which field of the database is this New Registration from?
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Dear Yuki thank you for your important reply, please check the below image and i have explain more to understand, and added two more dates in below image url
Which field of the database is this new registration from.
See i have told in above question registration table just you have to write
counts base on date in new registration and
cumulative registration counts you have to write sum of all previous date counts, same concept to applications
new application and cumulative application.
I think you to pass start date and end date static in linq query like start date will be
1 sept 2018 and End date will be till today.
Just i am explain to get the concept and you write your own way to achieve this thank you in advance.
According to your description,I think if you want to achieve it by linq ,you need to loop nested loops.
If so,once the data is wrong, you will not be able to debug the code.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
According to the screenshot and your description, I suggest you could refer to the following code:
using join clause to get the date list, then according to the date to get the new/cummulative columns.
DateTime dt2 = new DateTime(2018, 09, 02, 13, 08, 32, 303);
DateTime dt1 = new DateTime(2018, 09, 01, 13, 08, 32, 303);
List<Registration> reglist = new List<Registration>()
{
new Registration(){ Name="Mazhar",Email="m@gmail.com ",RegDate=dt2 },
new Registration(){ Name="mohan",Email="n@gmail.com",RegDate=dt1 },
new Registration(){ Name="kjdj",Email="k@gmail.com",RegDate=dt1},
};
List<Application> applist = new List<Application>()
{
new Application(){ Title="kk", Sector="jj", AppDate=dt2},
new Application(){ Title="mm", Sector="tt", AppDate=dt1},
};
var datalist = (from cc in reglist
join aa in applist on cc.RegDate equals aa.AppDate
group cc by cc.RegDate into newgroup
select new
{
date = newgroup.Key.ToShortDateString(),
NewRegistration = reglist.Where(c => c.RegDate == newgroup.Key).Count(),
CumulativeRegistration = reglist.Where(c => c.RegDate <= newgroup.Key).Count(),
NewApplication = applist.Where(c => c.AppDate == newgroup.Key).Count(),
CumulativeApplication = applist.Where(c => c.AppDate <= newgroup.Key).Count(),
}).ToList();
The out put as below:
You could also use Union to get the date list, code as below:
//get the date list var datelist = reglist.Select(c => c.RegDate).Union(applist.Select(c => c.AppDate)).ToList();
var datelist2 = (from cc in datelist
select new
{
date = cc.ToShortDateString(),
NewRegistration = reglist.Where(c => c.RegDate == cc).Count(),
CumulativeRegistration = reglist.Where(c => c.RegDate <= cc).Count(),
NewApplication = applist.Where(c => c.AppDate == cc).Count(),
CumulativeApplication = applist.Where(c => c.AppDate <= cc).Count(),
}).ToList();
Best regards,
Dillion
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
236 Points
575 Posts
I need linq query for report using mvc5 c#
Sep 09, 2018 05:33 AM|mazhar khan india|LINK
I need below result in linq query using mvc5
I am using below two tables Registration and Application to get above counts report base on Dates, from 1 Sept 2018 to till and grid should be date descending order as above output my report. New Registration means on that day how registration came, cumulative registrations means sum of registration counts on that particular day. And Application concept as same as registration.
1) Registration
2) Application
You can also check how cumulation count should in image view
enter image description here
I search lot but still not getting any idea, thank you in advance
Contributor
3710 Points
1431 Posts
Re: I need linq query for report using mvc5 c#
Sep 10, 2018 06:11 AM|Yuki Tao|LINK
HI mazhar khan india,
According to your description,I have some question:
where is the second item from?
Which field of the database is this New Registration from?
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
236 Points
575 Posts
Re: I need linq query for report using mvc5 c#
Sep 10, 2018 07:34 AM|mazhar khan india|LINK
Dear Yuki thank you for your important reply, please check the below image and i have explain more to understand, and added two more dates in below image url
https://imgur.com/a/VBsoV6V
Which field of the database is this new registration from.
See i have told in above question registration table just you have to write counts base on date in new registration and cumulative registration counts you have to write sum of all previous date counts, same concept to applications new application and cumulative application.
I think you to pass start date and end date static in linq query like start date will be 1 sept 2018 and End date will be till today.
Just i am explain to get the concept and you write your own way to achieve this thank you in advance.
Contributor
3710 Points
1431 Posts
Re: I need linq query for report using mvc5 c#
Sep 12, 2018 03:04 AM|Yuki Tao|LINK
Hi mazhar khan india,
According to your description,I think if you want to achieve it by linq ,you need to loop nested loops.
If so,once the data is wrong, you will not be able to debug the code.
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
All-Star
45489 Points
7008 Posts
Microsoft
Re: I need linq query for report using mvc5 c#
Sep 18, 2018 10:01 AM|Zhi Lv - MSFT|LINK
Hi Sir,
According to the screenshot and your description, I suggest you could refer to the following code:
using join clause to get the date list, then according to the date to get the new/cummulative columns.
The out put as below:
You could also use Union to get the date list, code as below:
Best regards,
Dillion