Click here to Skip to main content
14,574,365 members

.NET (Core and Framework)

 
PinnedHOW TO ANSWER A QUESTION Pin
Chris Maunder16-Jul-09 3:09
cofounderChris Maunder16-Jul-09 3:09 
PinnedHow to get an answer to your question Pin
Chris Maunder16-Jul-09 3:05
cofounderChris Maunder16-Jul-09 3:05 
QuestionHow to join two linq queries to find some common data between them Pin
ElenaRez22-Jun-20 11:16
MemberElenaRez22-Jun-20 11:16 
I have two linq queries like the following and their output results are correct:

var mytotal = _context.Apiapplicant.Where(c => !c.ApiRequestDate.Equals("") && c.IsDeleted.Equals(false)).GroupBy(o => new
            {
                Month = o.ApiRequestDate.Substring(5, 2),
                Year = o.ApiRequestDate.Substring(0, 4)
            }).Select(g => new
            {
                Month = g.Key.Month,
                Year = g.Key.Year,
                Total = g.Count()
            }).OrderByDescending(a => a.Year).ThenByDescending(a => a.Month).ToList();

The above query gives the total requests that was registerd in each month.

var numerator = from t1 in _context.Apiapplicant
                            join t2 in _context.ApiApplicantHistory on t1.Id equals t2.ApiApplicantId
                            join t3 in _context.EntityType on t2.LastReqStatus equals t3.Id
                            //join t4 in mytotal on new { t2.Date.Substring(0,4), t2.Date.Substring(2,5) } equals new { t4.Year, t4.Month }
                            // join t4 in mytotal on  t2.Date.Substring(2, 5) equals t4.Month

                            where t1.IsDeleted == false && t3.Name == "granted" && t2.Date != null && t1.ApiRequestNo != null

                            group t1
                            by new
                            {
                                lastReq = t2.LastReqStatus,
                                Year = t2.Date.Substring(0, 4),
                                Month = t2.Date.Substring(5, 2)
                            } into g

                            select new
                            {
                                Year = g.Key.Year,
                                Month = g.Key.Month,
                                lastReq = g.Key.lastReq,
                                GrantedCount = g.Count()
                            };


            var GrantedReqStatus = numerator.OrderByDescending(x => x.Year).ThenByDescending(a => a.Month).ToList();


The above query gives total requests for each month that has "granted" status. Now I want to find for all the requests that are registered in each month, how many of them has "granted" status. To obtain it, I've made a query like the following which should join both GrantedReqStatus and mytotal queries:

var LastGrantedStatus = (from t1 in mytotal
                                    from t2 in GrantedReqStatus
                                    where (t1.Month == t2.Month) && (t1.Year == t2.Year)
                                    group t1
                            by new
                            {
                                //  lastReq = t2.LastReqStatus,
                                Year = t1.Year,
                                Month = t1.Month
                            } into g
                                    select new {  Month=g.Key.Month, Year=g.Key.Year,grcount = g.Count()}).ToList();


But when I run the project, the following expressions doesn't print anything:


Console.WriteLine("LastGrantedStatus.Count:" + LastGrantedStatus.Count);
            foreach (var t in LastGrantedStatus)
            {
                Console.WriteLine("t.GrantedCount + t.Month:" + t.Month + "+" + t.grcount); //+ "+" + t. + "+" + t.Year);
            }

QuestionHow to retrieve user's data from active directory by novell.Directory.LDap.NetStandard library Pin
ElenaRez22-Jun-20 0:05
MemberElenaRez22-Jun-20 0:05 
AnswerRe: How to retrieve user's data from active directory by novell.Directory.LDap.NetStandard library Pin
Dave Kreskowiak22-Jun-20 3:45
mveDave Kreskowiak22-Jun-20 3:45 
QuestionGetting “Unable to connect to the remote server” When I call WebAPI Url (C#) Pin
sfd16-Jun-20 0:17
Membersfd16-Jun-20 0:17 
AnswerRe: Getting “Unable to connect to the remote server” When I call WebAPI Url (C#) Pin
Richard Deeming16-Jun-20 0:34
mveRichard Deeming16-Jun-20 0:34 
QuestionSecuring Net Core API Pin
pkfox12-Jun-20 4:04
professionalpkfox12-Jun-20 4:04 
AnswerRe: Securing Net Core API Pin
Pete O'Hanlon12-Jun-20 5:29
subeditorPete O'Hanlon12-Jun-20 5:29 
GeneralRe: Securing Net Core API Pin
pkfox12-Jun-20 8:15
professionalpkfox12-Jun-20 8:15 
QuestionSMTP authentication oddities Pin
DerekT-P7-Jun-20 11:21
professionalDerekT-P7-Jun-20 11:21 
AnswerRe: SMTP authentication oddities Pin
Richard Deeming8-Jun-20 0:00
mveRichard Deeming8-Jun-20 0:00 
GeneralRe: SMTP authentication oddities Pin
DerekT-P8-Jun-20 0:59
professionalDerekT-P8-Jun-20 0:59 
GeneralLooking for a (free) .NET pluralizer / singularizer Pin
Sander Rossel3-Jun-20 1:11
professionalSander Rossel3-Jun-20 1:11 
GeneralRe: Looking for a (free) .NET pluralizer / singularizer Pin
Garth J Lancaster3-Jun-20 1:17
professionalGarth J Lancaster3-Jun-20 1:17 
GeneralRe: Looking for a (free) .NET pluralizer / singularizer Pin
Sander Rossel3-Jun-20 3:52
professionalSander Rossel3-Jun-20 3:52 
GeneralRe: Looking for a (free) .NET pluralizer / singularizer Pin
#realJSOP22-Jun-20 4:19
mva#realJSOP22-Jun-20 4:19 
JokeRe: Looking for a (free) .NET pluralizer / singularizer Pin
Richard Deeming3-Jun-20 1:34
mveRichard Deeming3-Jun-20 1:34 
GeneralRe: Looking for a (free) .NET pluralizer / singularizer Pin
Richard MacCutchan3-Jun-20 2:14
mveRichard MacCutchan3-Jun-20 2:14 
GeneralRe: Looking for a (free) .NET pluralizer / singularizer Pin
Sander Rossel3-Jun-20 3:52
professionalSander Rossel3-Jun-20 3:52 
GeneralRe: Looking for a (free) .NET pluralizer / singularizer Pin
Richard Deeming3-Jun-20 4:24
mveRichard Deeming3-Jun-20 4:24 
GeneralRe: Looking for a (free) .NET pluralizer / singularizer Pin
Sander Rossel3-Jun-20 4:48
professionalSander Rossel3-Jun-20 4:48 
GeneralRe: Looking for a (free) .NET pluralizer / singularizer Pin
pkfox13-Jun-20 5:30
professionalpkfox13-Jun-20 5:30 
GeneralRe: Looking for a (free) .NET pluralizer / singularizer Pin
Sander Rossel13-Jun-20 23:53
professionalSander Rossel13-Jun-20 23:53 
Questionport 5xxxx is already in use, unable to connect to web server IIS Express Pin
Member 109358009-May-20 3:35
MemberMember 109358009-May-20 3:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.