Click here to Skip to main content
15,886,362 members
Home / Discussions / C#
   

C#

 
GeneralRe: Passing a variable from an string to a For loop Pin
OriginalGriff14-Aug-21 1:35
mveOriginalGriff14-Aug-21 1:35 
GeneralRe: Passing a variable from an string to a For loop Pin
Alex Dunlop13-Aug-21 7:39
Alex Dunlop13-Aug-21 7:39 
QuestionHow to split an string and remove extra spaces Pin
Alex Dunlop10-Aug-21 22:55
Alex Dunlop10-Aug-21 22:55 
AnswerRe: How to split an string and remove extra spaces Pin
Richard MacCutchan10-Aug-21 23:39
mveRichard MacCutchan10-Aug-21 23:39 
AnswerRe: How to split an string and remove extra spaces Pin
Pete O'Hanlon11-Aug-21 7:33
mvePete O'Hanlon11-Aug-21 7:33 
GeneralRe: How to split an string and remove extra spaces Pin
OriginalGriff11-Aug-21 7:58
mveOriginalGriff11-Aug-21 7:58 
QuestionLinq To SQL Join Question Pin
Kevin Marois9-Aug-21 6:35
professionalKevin Marois9-Aug-21 6:35 
AnswerRe: Linq To SQL Join Question Pin
Richard Deeming9-Aug-21 21:03
mveRichard Deeming9-Aug-21 21:03 
Assuming you have a navigation property, you may be able to do something like this:
C#
var jobStartDates = dc.JobStartDates.AsNoTracking().Include(jsd => jsd.Revisions).Where(jsd => jsd.JobId == jobId).ToList();
var results = jobStartDates.Select(jsd => new JobStartDateEntity
{
    Id = jsd.Id,
    ...
    StartDateRevisions = jsd.Revisions.Select(sdr => new JobStartDateRevisionEntry
    {
        Id = sdr.Id,
        ...
    }).OrderByDescending(sdr => sdr.Revision).ToList(),
});

Alternatively, you can do it with two queries, rather than N+1 queries:
C#
var results = (from jsd in dc.JobStartDates
               where jsd.JobId == jobId
               select new JobStartDateEntity
               {
                   ...
               }).ToList();

var jobStartDateIds = results.Select(jsd => jsd.Id).ToList();

var revisions = dc.JobStartDateRevisions
    .Where(sdr => jobStartDateIds.Contains(sdr.Id))
    .Select(sdr => new JobStartDateRevisionEntity { ... })
    .ToList();

forech (var result in results)
{
    result.StartDateRevisions = revisions
        .Where(sdr => sdr.Id == result.Id)
        .OrderByDescending(sdr => sdr.Revision)
        .ToList();
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

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

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.