Solved

Linq contains. ???

Posted on 2012-04-01
7
340 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 74

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 74

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now