Solved

Linq contains. ???

Posted on 2012-04-01
7
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Industry Leaders: 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

Suggested Solutions

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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