Click here to Skip to main content
15,561,422 members
Home / Discussions / C#
   

C#

 
GeneralRe: Passing a variable from an string to a For loop Pin
Alex Dunlop13-Aug-21 8:31
Alex Dunlop13-Aug-21 8:31 
GeneralRe: Passing a variable from an string to a For loop Pin
OriginalGriff14-Aug-21 2:35
mveOriginalGriff14-Aug-21 2:35 
GeneralRe: Passing a variable from an string to a For loop Pin
Alex Dunlop13-Aug-21 8:39
Alex Dunlop13-Aug-21 8:39 
QuestionHow to split an string and remove extra spaces Pin
Alex Dunlop10-Aug-21 23:55
Alex Dunlop10-Aug-21 23:55 
AnswerRe: How to split an string and remove extra spaces Pin
Richard MacCutchan11-Aug-21 0:39
mveRichard MacCutchan11-Aug-21 0:39 
AnswerRe: How to split an string and remove extra spaces Pin
Pete O'Hanlon11-Aug-21 8:33
mvaPete O'Hanlon11-Aug-21 8:33 
GeneralRe: How to split an string and remove extra spaces Pin
OriginalGriff11-Aug-21 8:58
mveOriginalGriff11-Aug-21 8:58 
QuestionLinq To SQL Join Question Pin
Kevin Marois9-Aug-21 7:35
professionalKevin Marois9-Aug-21 7:35 
I have this method that returns a List<jobstartdate>. Each start date can have 1-n revisions. So after I get the start dates I then loop through them all and get the revisions for each one.

My question is this... is it possible to somehow do this all in one query without having to loop and get the child records? Can I somehow select the joined records into entities in the same query as the start dates?
<pre>public List<JobStartDateEntity> GetJobStartDates(int jobId)
{
using (var dc = GetDataContext())
{
    var results = (from jsd in dc.JobStartDates
                    where jsd.JobId == jobId
                    select new JobStartDateEntity
                    {
                        Id = jsd.Id,
                        StartDateId = jsd.StartDateId ?? 0,
                        JobId = jobId,
                        ProjectStartDateId = jsd.ProjectStartDateId,
                        Caption = jsd.Caption,
                        Description = jsd.Description,
                        Sequence = jsd.Sequence,
                        DaysOffset = jsd.DaysOffset,
                        StartDate = jsd.StartDate
                    }).ToList();

    foreach (var result in results)
    {
        var startDateRevisions = (from sdr in dc.JobStartDateRevisions
                                    where sdr.Id == result.Id
                                    select new JobStartDateRevisionEntity
                                    { 
                                        Id = sdr.Id,
                                        JobId = sdr.JobId,
                                        StartDate = sdr.StartDate,
                                        Revision = sdr.Revision
                                    }).OrderByDescending(x => x.Revision).ToList();

        result.StartDateRevisions = startDateRevisions;
    }

    return results;
}
}

If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: Linq To SQL Join Question Pin
Richard Deeming9-Aug-21 22:03
mveRichard Deeming9-Aug-21 22:03 
GeneralRe: Linq To SQL Join Question Pin
Nathan Minier10-Aug-21 6:46
professionalNathan Minier10-Aug-21 6:46 
QuestionHow to check Persian date format? Pin
Alex Dunlop7-Aug-21 21:19
Alex Dunlop7-Aug-21 21:19 
AnswerRe: How to check Persian date format? Pin
OriginalGriff7-Aug-21 21:22
mveOriginalGriff7-Aug-21 21:22 
GeneralRe: How to check Persian date format? Pin
Alex Dunlop7-Aug-21 21:37
Alex Dunlop7-Aug-21 21:37 
QuestionNotifications in win c# Pin
Member 149572104-Aug-21 18:35
Member 149572104-Aug-21 18:35 
AnswerRe: Notifications in win c# Pin
OriginalGriff4-Aug-21 20:43
mveOriginalGriff4-Aug-21 20:43 
QuestionError when importing a class dll Pin
Alex Dunlop3-Aug-21 23:42
Alex Dunlop3-Aug-21 23:42 
AnswerRe: Error when importing a class dll Pin
Richard Deeming4-Aug-21 0:44
mveRichard Deeming4-Aug-21 0:44 
GeneralRe: Error when importing a class dll Pin
Alex Dunlop4-Aug-21 1:54
Alex Dunlop4-Aug-21 1:54 
GeneralRe: Error when importing a class dll Pin
Alex Dunlop4-Aug-21 9:44
Alex Dunlop4-Aug-21 9:44 
GeneralRe: Error when importing a class dll Pin
Richard Deeming4-Aug-21 23:05
mveRichard Deeming4-Aug-21 23:05 
AnswerRe: Error when importing a class dll Pin
Richard MacCutchan4-Aug-21 2:31
mveRichard MacCutchan4-Aug-21 2:31 
GeneralRe: Error when importing a class dll Pin
Richard Andrew x644-Aug-21 8:29
professionalRichard Andrew x644-Aug-21 8:29 
GeneralRe: Error when importing a class dll Pin
Richard MacCutchan4-Aug-21 8:32
mveRichard MacCutchan4-Aug-21 8:32 
GeneralRe: Error when importing a class dll Pin
Bohdan Stupak6-Aug-21 6:06
professionalBohdan Stupak6-Aug-21 6:06 
AnswerRe: Error when importing a class dll Pin
BillWoodruff8-Aug-21 21:30
professionalBillWoodruff8-Aug-21 21:30 

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.