?
Solved

Linq contains. ???

Posted on 2012-04-01
7
Medium Priority
?
350 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 20

Accepted Solution

by:
BuggyCoder earned 1600 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 400 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Screencast - Getting to Know the Pipeline
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

862 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