Click here to Skip to main content
15,905,782 members
Home / Discussions / C#
   

C#

 
GeneralRe: How filter a DataGridView filled from csv file... Pin
grennday24-Jun-22 21:14
grennday24-Jun-22 21:14 
QuestionIVideoWindow.SetWindowPosition not working Pin
Le@rner8-Jun-22 21:18
Le@rner8-Jun-22 21:18 
AnswerRe: IVideoWindow.SetWindowPosition not working Pin
OriginalGriff8-Jun-22 21:53
mveOriginalGriff8-Jun-22 21:53 
QuestionLists C# Pin
Rui Couto6-Jun-22 3:23
Rui Couto6-Jun-22 3:23 
AnswerRe: Lists C# Pin
OriginalGriff6-Jun-22 3:54
mveOriginalGriff6-Jun-22 3:54 
GeneralRe: Lists C# Pin
Rui Couto6-Jun-22 5:16
Rui Couto6-Jun-22 5:16 
GeneralRe: Lists C# Pin
OriginalGriff6-Jun-22 5:54
mveOriginalGriff6-Jun-22 5:54 
GeneralRe: Lists C# Pin
James Curran21-Jun-22 7:31
James Curran21-Jun-22 7:31 
GeneralRe: Lists C# Pin
OriginalGriff21-Jun-22 11:26
mveOriginalGriff21-Jun-22 11:26 
AnswerRe: Lists C# Pin
James Curran21-Jun-22 7:52
James Curran21-Jun-22 7:52 
GeneralRe: Lists C# Pin
Rui Couto29-Jun-22 23:51
Rui Couto29-Jun-22 23:51 
QuestionMixed mode assembly is built against version 'v2.0.50727' Pin
Le@rner2-Jun-22 0:38
Le@rner2-Jun-22 0:38 
AnswerRe: Mixed mode assembly is built against version 'v2.0.50727' Pin
OriginalGriff2-Jun-22 1:43
mveOriginalGriff2-Jun-22 1:43 
GeneralRe: Mixed mode assembly is built against version 'v2.0.50727' Pin
Richard MacCutchan2-Jun-22 2:19
mveRichard MacCutchan2-Jun-22 2:19 
GeneralRe: Mixed mode assembly is built against version 'v2.0.50727' Pin
Le@rner2-Jun-22 17:10
Le@rner2-Jun-22 17:10 
GeneralRe: Mixed mode assembly is built against version 'v2.0.50727' Pin
Richard Deeming5-Jun-22 21:49
mveRichard Deeming5-Jun-22 21:49 
GeneralRe: Mixed mode assembly is built against version 'v2.0.50727' Pin
Le@rner5-Jun-22 22:34
Le@rner5-Jun-22 22:34 
Questionasync-await block Pin
j11codep31-May-22 16:46
j11codep31-May-22 16:46 
AnswerRe: async-await block Pin
Richard Deeming31-May-22 21:44
mveRichard Deeming31-May-22 21:44 
QuestionAdding items to a list updates all previous items Pin
Code4Ever27-May-22 5:58
Code4Ever27-May-22 5:58 
I want to convert dates come from database. I have the following API action:

[HttpGet]
public async Task<IActionResult> GetSpecialPostsList()
{
    var posts = await myContext.Posts.Where(x => x.IsSpecialPost == true && x.IsActive == true).ToListAsync();
    if (posts != null)
    {
        var revisedPost = new RevisedPost();
        var revisedPostList = new List<RevisedPost>();
        foreach (var post in posts)
        {
            revisedPost.CreationDate = DateConverter.GregToPersianDate(post.CreationDate.ToShortDateString());
            revisedPost.Description = post.Description;
            revisedPost.ImageFileName = post.ImageFileName;
            revisedPost.IsActive = post.IsActive;
            revisedPost.IsMainPost = post.IsMainPost;
            revisedPost.IsSpecialPost = post.IsSpecialPost;
            revisedPost.Title = post.Title;
            revisedPost.Id = post.Id;

            revisedPostList.Add(revisedPost);
        }
        return Ok(revisedPostList);
    }
    return NotFound("Data not found!");
}


The problem is that when new data is added to the list, all the items in the list are updated to the latest item values. This means all the items in the list are the same.
What is wrong with my code? Confused | :confused:
AnswerRe: Adding items to a list updates all previous items Pin
Gerry Schmitz27-May-22 6:21
mveGerry Schmitz27-May-22 6:21 
GeneralRe: Adding items to a list updates all previous items Pin
Code4Ever27-May-22 6:31
Code4Ever27-May-22 6:31 
AnswerRe: Adding items to a list updates all previous items Pin
James Curran21-Jun-22 7:55
James Curran21-Jun-22 7:55 
QuestionHow do I add text via c# to an OPEN Excel Workbook? Pin
jrdnoland18-May-22 11:21
jrdnoland18-May-22 11:21 
AnswerRe: How do I add text via c# to an OPEN Excel Workbook? Pin
OriginalGriff18-May-22 19:18
mveOriginalGriff18-May-22 19:18 

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.