locked
Return null fields from a listing RRS feed

  • Question

  • User1670624291 posted

    Hi,

    I currently have the code below to perform the filtering of the status field.

    It works well with values or string, but I intend to list where the status field is null, in my idea replacing the value or the string with null would result, but when I run it is returned zero values. 

    if (startStatus == "Vazio")
                {
                    proResult = proResult.Select(x => new OrdersColorsViewModel
                    {
                        order = x.order,
                        malha = x.malha,
                        preco = x.preco,
                        promalha = x.promalha,
                        colers = x.colers.Where(c => c.status.Any(k => k.Status == null)).ToList()
                    }).Where(m => m.colers.Count() != 0);
                }

    I did a little test on my view and it works well

    @foreach (var item4 in item2.status.Where(x => x == null))

    Is any difference in reading the null state being made?

    for those who want to have a little idea of what's going on: https://forums.asp.net/t/2174909.aspx?List+status+by+line

    thanks,

    Wednesday, May 26, 2021 2:56 PM

Answers

  • User287926715 posted

    Hi MiguelMi,

    Does your test data have the value of Status as null?

    If there is none in the test data, the number is 0. You can check the value of proResult.

    Best Regards,

    ChaoDeng

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 27, 2021 9:13 AM
  • User1670624291 posted

    Hi,

    Yes some of my Status fields are as null in the database, and I intend to return them as you can see on the image.

    in my logic (Status == null) it was supposed to work like that,(Status == "Status1")  right? 

    thanks

    update: logic works!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 27, 2021 10:02 AM

All replies

  • User287926715 posted

    Hi MiguelMi,

    Does your test data have the value of Status as null?

    If there is none in the test data, the number is 0. You can check the value of proResult.

    Best Regards,

    ChaoDeng

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 27, 2021 9:13 AM
  • User1670624291 posted

    Hi,

    Yes some of my Status fields are as null in the database, and I intend to return them as you can see on the image.

    in my logic (Status == null) it was supposed to work like that,(Status == "Status1")  right? 

    thanks

    update: logic works!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 27, 2021 10:02 AM