Click here to Skip to main content
15,916,318 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to update members of a List using Linq? Pin
Richard Deeming27-Jan-21 4:10
mveRichard Deeming27-Jan-21 4:10 
GeneralRe: How to update members of a List using Linq? Pin
Dave Kreskowiak27-Jan-21 7:06
mveDave Kreskowiak27-Jan-21 7:06 
QuestionProper event handling in docked window schema Pin
gizbernus26-Jan-21 9:16
gizbernus26-Jan-21 9:16 
Questionalias names for Column in Linq Pin
simpledeveloper25-Jan-21 8:28
simpledeveloper25-Jan-21 8:28 
Hi I have a linq query in the following way where two column names from 2 different tables is same, which is giving me error, can somebody please help me in this? How to resolve with alias names if the names are same from 2 different tables and they are used either in select or in group - thank you so much in advance.

Here is my linq query:
ViolationsUniquePenaltyApplied = (from a in violations
                                  join b in programs on a.ViolationTypeId equals b.ViolationTypeId
                                  join d in branches on b.BranchId equals d.BranchId
                                  join e in programs on a.ViolationSubtypeId equals e.ViolationTypeId into es from e in es.DefaultIfEmpty()
                                  where a.ApplyUniquePenalty == true
                                  group new { a.ViolationSubtypeId, e.ViolationTypeName, a?.ViolationTypeId, b?.ViolationTypeName, b?.ParentViolationId, d?.BranchId, d?.Name, a.PenaltyAssessed, a.ViolationId, a.ViolationNumber }
                                  by new { a?.ViolationTypeId, b?.ViolationTypeName, d?.BranchId, d?.Name, a.ViolationId }
                    into g
                                  select new
                                  {
                                      ViolationTypeId = g.FirstOrDefault().ViolationTypeId,
                                      ViolationType = g.FirstOrDefault().ViolationTypeName,
                                      ParentViolationType = (g.FirstOrDefault()?.ParentViolationId != null) ? (from e in programs where g.FirstOrDefault()?.ViolationTypeId == e.ParentViolationId select e.ViolationTypeName)?.FirstOrDefault() : g.FirstOrDefault().ViolationTypeName,
                                      BranchId = g.FirstOrDefault().BranchId,
                                      Branch = g.FirstOrDefault().Name,
                                      PenaltyAssessed = g.Sum(pc => pc.PenaltyAssessed),
                                      Cnt = g.Count(),
                                      ViolationNumber = g.FirstOrDefault().ViolationNumber,
                                      CountOrId = (g.Count() == 1) ? g.Count() : g.FirstOrDefault().ViolationId,
                                      PenaltyPerUnit = g.Sum(pc => pc.PenaltyAssessed) / g.Count()
                                  })

AnswerRe: alias names for Column in Linq Pin
Gerry Schmitz25-Jan-21 10:18
mveGerry Schmitz25-Jan-21 10:18 
AnswerRe: alias names for Column in Linq Pin
Richard Deeming25-Jan-21 21:38
mveRichard Deeming25-Jan-21 21:38 
Questionhow to print POS bills with a thermal printer Pin
Meax24-Jan-21 8:53
Meax24-Jan-21 8:53 
AnswerRe: how to print POS bills with a thermal printer Pin
Daniel Pfeffer24-Jan-21 9:23
professionalDaniel Pfeffer24-Jan-21 9:23 
GeneralRe: how to print POS bills with a thermal printer Pin
OriginalGriff24-Jan-21 10:25
mveOriginalGriff24-Jan-21 10:25 
AnswerRe: how to print POS bills with a thermal printer Pin
OriginalGriff24-Jan-21 10:26
mveOriginalGriff24-Jan-21 10:26 
QuestionRuntime error in PivotGridControl data binding [Solved] Pin
Alex Dunlop21-Jan-21 8:48
Alex Dunlop21-Jan-21 8:48 
AnswerRe: Runtime error in PivotGridControl data binding Pin
Gerry Schmitz21-Jan-21 9:02
mveGerry Schmitz21-Jan-21 9:02 
AnswerRe: Runtime error in PivotGridControl data binding Pin
Richard Deeming21-Jan-21 22:05
mveRichard Deeming21-Jan-21 22:05 
AnswerRe: Runtime error in PivotGridControl data binding Pin
OriginalGriff21-Jan-21 22:22
mveOriginalGriff21-Jan-21 22:22 
GeneralRe: Runtime error in PivotGridControl data binding Pin
Alex Dunlop21-Jan-21 22:44
Alex Dunlop21-Jan-21 22:44 
GeneralRe: Runtime error in PivotGridControl data binding Pin
Alex Dunlop21-Jan-21 23:07
Alex Dunlop21-Jan-21 23:07 
GeneralRe: Runtime error in PivotGridControl data binding Pin
OriginalGriff21-Jan-21 23:30
mveOriginalGriff21-Jan-21 23:30 
Question[Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 0:34
chipp_zanuff21-Jan-21 0:34 
AnswerRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
OriginalGriff21-Jan-21 0:59
mveOriginalGriff21-Jan-21 0:59 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 5:56
chipp_zanuff21-Jan-21 5:56 
AnswerRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Richard MacCutchan21-Jan-21 1:37
mveRichard MacCutchan21-Jan-21 1:37 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 5:40
chipp_zanuff21-Jan-21 5:40 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Richard MacCutchan21-Jan-21 5:53
mveRichard MacCutchan21-Jan-21 5:53 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
chipp_zanuff21-Jan-21 6:03
chipp_zanuff21-Jan-21 6:03 
GeneralRe: [Visual Studio 2019] Ask About Tutorial for C# Windows Application Pin
Richard MacCutchan21-Jan-21 6:36
mveRichard MacCutchan21-Jan-21 6:36 

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.