Solved

Linq contains. ???

Posted on 2012-04-01
7
345 Views
Last Modified: 2012-04-01
Guys, I'm receiving a exception  NULL object with this command.

But my list has 260 object. I just want filter by customer passing some value from a Text component.

Does any one could tell me what's wrong ?

FilteredList = _ManagmentoDTO._Processing._Order._OrderMList.Where(s => s.Customer.StartsWith(txt_filter_Value.Text)).ToList();

Many Thansk
0
Comment
Question by:Mortarello
  • 4
  • 2
7 Comments
 

Author Comment

by:Mortarello
ID: 37793698
I tryied StartWith and Constraint get the same erro, and my list has data.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37793761
If the Customer property (among other potential candidates in that line) hasn't been properly initialized, then you will receive this error.
0
 

Author Comment

by:Mortarello
ID: 37793809
Hi kaufmed,

Thanks to try to help me, but the data i can see on Datagrid. i'm just trying to filter then.

In my collection I've got 260 objects with all fields in there. this is very weird.
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 20

Accepted Solution

by:
BuggyCoder earned 400 total points
ID: 37793813
Assuming that s.customer returns string, here is a modified version which checks if the customer is not null or empty:-

FilteredList =
_ManagmentoDTO._Processing._Order._OrderMList
.Where(s => (!string.isNullOrEmpty(s.Customer) && s.Customer.StartsWith(txt_filter_Value.Text))).ToList();

This will filter out customer with null or empty data....
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 100 total points
ID: 37793815
Try clicking in this part of that line:  ...txt_filter_Value.Text...

...then, hit F9 to set a breakpoint. Then run your application. When the lambda is executed, your code will break on that new breakpoint. Then you can step through one-by-one to see which entry raises the exception. Then it becomes a matter of figuring out why whichever member is null.
0
 

Author Comment

by:Mortarello
ID: 37793820
I will double check my list again..
0
 

Author Comment

by:Mortarello
ID: 37793854
Tks guys
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question