0

This is my linq query but here I am not getting null. In the result set in jquery code I am getting null

var Data = await (from Names in apiDbContext.name.AsNoTracking()
   .Where(a => a.IsActive == true) orderby NamesList.Name select NamesList)
   .ToListAsync(); 

Below is my screen shot where i am getting null in the data because of this null i am getting error

Uncaught TypeError: Cannot read property 'username' of null.

$.ajax({
      type: "GET",
      url: remote_url,
      async: false,
      success: function(data) { 
    /* Near this data i am getting last record as null because of this 
       I am getting error as Cannot read property 'username' of null  */
        $.each(data, function(key, val) {
          var title = val[Text];
        })
      })
5
  • 1
    You can filtered values in backend code.for example with linq array.Where(q=> !string.IsNullOrEmpty(q)) Commented Dec 10, 2020 at 11:58
  • var arr = ["",1,2,3,4,5,6,'123',33,'asd',"",'',1,'']; arr = arr.filter(function(value) { return value !== "" && value !== null; }); console.log(arr); ... for more details stackoverflow.com/questions/12745800/… Commented Dec 10, 2020 at 11:58
  • I had already tried this parth but still i am getting the same exception Commented Dec 10, 2020 at 12:01
  • To remove empty null or blank values from an array please check this answer Commented Dec 10, 2020 at 12:02
  • var Data = await (from Names in apiDbContext.name.AsNoTracking().Where(a => a.IsActive == true) orderby NamesList.Name select NamesList).ToListAsync(); this is my linq query but here i am not getting null in the result set in jquery code i am getting null Commented Dec 10, 2020 at 12:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.