Click here to Skip to main content
15,347,000 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralCalling Paul Griffin Pin
pkfox17-Feb-21 6:13
professionalpkfox17-Feb-21 6:13 
JokeRe: Calling Paul Griffin Pin
User 1502577517-Feb-21 6:24
MemberUser 1502577517-Feb-21 6:24 
GeneralRe: Calling Paul Griffin Pin
Slacker00717-Feb-21 6:41
professionalSlacker00717-Feb-21 6:41 
GeneralRe: Calling Paul Griffin Pin
OriginalGriff17-Feb-21 6:45
mveOriginalGriff17-Feb-21 6:45 
GeneralRe: Calling Paul Griffin Pin
RickZeeland17-Feb-21 6:45
mveRickZeeland17-Feb-21 6:45 
GeneralRe: Calling Paul Griffin Pin
OriginalGriff17-Feb-21 7:07
mveOriginalGriff17-Feb-21 7:07 
GeneralRe: Calling Paul Griffin Pin
pkfox17-Feb-21 7:22
professionalpkfox17-Feb-21 7:22 
GeneralLINQ is fun! Pin
Marc Clifton17-Feb-21 5:32
mvaMarc Clifton17-Feb-21 5:32 
Especially when combined with extension methods and fluent-style methods.
envvars
    .Municipalities()
    .Select(m => m.Fixups())
    .NotServiceAccess()
    .Where(m => m.VerifyConnection(_ => Log($"{m.Municipality}: {m.ConnectionString} => Connection failed.")))
    .Do(munis =>
        munis.SelectWith(m => M5.GetTableNames(AUDIT_SCHEMA, m.ConnectionString), (m, with) => (auditableEntities.NotIn(with, s => s.TableName.ToLower(), t => t.ToLower()), m))
        .ForEach(q => q
            .Iterate((t, m) =>
                t
                    .Do(_ => Log($"{m.Municipality}: {t.TableName} => Audit table missing"))
                    .GenerateMissingAuditTableSql(m)
                    .Execute(m.ConnectionString, (sql, e) => Log($"{m.Municipality}: {t.TableName} => {e.Message}\r\nFailed to execute SQL: {sql.ToString()}"))
            )))
        .Do(munis =>
        {
            munis.SelectWith(m => M5.GetTableNames(AUDIT_SCHEMA, m.ConnectionString), (m, with) => (auditableEntities.In(with, s => s.TableName.ToLower(), t => t.ToLower()), m))
            .ForEach(q => q
                .Iterate((t, m) =>
                {
                    Log($"{m.Municipality}: {t.TableName} => Checking...");
                    var entityColumns = M5.GetColumnList(DBO_SCHEMA, m.ConnectionString, t.TableName);
                    var auditColumns = M5.GetColumnList(AUDIT_SCHEMA, m.ConnectionString, t.TableName);

                    entityColumns.NotIn(auditColumns, s => s.Name.ToLower(), f => f.Name.ToLower())
                        .DoIf(q2 => q2.Count() > 0, q3 => Log($"  {q3.Count()} missing fields"))
                        .ForEach(f =>
                        {
                            Log($"  {m.Municipality}: {t.TableName} => Field {f} missing in audit table");

                            f
                                .GenerateMissingColumnSql(m, AUDIT_SCHEMA, t.TableName)
                                .Execute(m.ConnectionString, (sql, e) => Log($"{m.Municipality}: {t.TableName} => {e.Message}\r\nFailed to execute SQL: {sql.ToString()}"));
                        });
                }));
        });


This is a custom "one line" function that creates missing audit tables or adds the missing columns that the entity defines but someone forgot to add to the audit table.

Big Grin | :-D

GeneralRe: LINQ is fun! Pin
Dave Kreskowiak17-Feb-21 5:41
mveDave Kreskowiak17-Feb-21 5:41 
GeneralRe: LINQ is fun! Pin
Eddy Vluggen17-Feb-21 5:51
professionalEddy Vluggen17-Feb-21 5:51 
GeneralRe: LINQ is fun! Pin
PIEBALDconsult17-Feb-21 9:55
professionalPIEBALDconsult17-Feb-21 9:55 
QuestionRe: LINQ is fun! Pin
Eddy Vluggen17-Feb-21 11:19
professionalEddy Vluggen17-Feb-21 11:19 
GeneralRe: LINQ is fun! Pin
Chris Losinger17-Feb-21 6:16
professionalChris Losinger17-Feb-21 6:16 
GeneralRe: LINQ is fun! Pin
Maximilien17-Feb-21 6:24
MemberMaximilien17-Feb-21 6:24 
GeneralRe: LINQ is fun! Pin
Dan Neely17-Feb-21 9:57
MemberDan Neely17-Feb-21 9:57 
GeneralRe: LINQ is fun! Pin
Marc Clifton18-Feb-21 0:42
mvaMarc Clifton18-Feb-21 0:42 
GeneralRe: LINQ is fun! Pin
Dan Neely18-Feb-21 3:32
MemberDan Neely18-Feb-21 3:32 
GeneralRe: LINQ is fun! Pin
obermd18-Feb-21 3:19
Memberobermd18-Feb-21 3:19 
GeneralRe: LINQ is fun! Pin
James Curran18-Feb-21 6:16
MemberJames Curran18-Feb-21 6:16 
GeneralRe: LINQ is fun! Pin
Sander Rossel17-Feb-21 9:35
professionalSander Rossel17-Feb-21 9:35 
GeneralRe: LINQ is fun! Pin
  Forogar  17-Feb-21 9:54
professional  Forogar  17-Feb-21 9:54 
PraiseRe: LINQ is fun! Pin
Stepan Hakobyan17-Feb-21 19:56
professionalStepan Hakobyan17-Feb-21 19:56 
GeneralRe: LINQ is fun! Pin
den2k8817-Feb-21 21:33
professionalden2k8817-Feb-21 21:33 
GeneralRe: LINQ is fun! Pin
Marc Clifton18-Feb-21 0:42
mvaMarc Clifton18-Feb-21 0:42 
GeneralRe: LINQ is fun! Pin
den2k8817-Feb-21 21:33
professionalden2k8817-Feb-21 21:33 

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.


Straw Poll

You discover a sentient AI in your org's system. What do you do?
Well you never know what sort of orphaned projects previous employees have left behind...
  Results   591 votes