Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ListView height inside of a StackPanel - problem...
Message
From
20/06/2008 13:55:08
 
 
To
20/06/2008 13:49:08
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01325263
Message ID:
01325829
Views:
13
You're welcome.<g>

>DUDE!!!! You are so smart with this stuff.
>
>I'm not even kidding.... I just posted a boo-hoo about an error I was getting on casting the object type, and you had already replied with a prediction about how using "var" was going to cause the exact problem that I ran into.
>
>
>You were right on it!
>
>I had to revise my Linq call just like you said:
>
>
>            IEnumerable<customer_source> customers = from a in db.customers
>                                                     where SqlMethods.Like(a.custno, CustomerFilter) || SqlMethods.Like(a.company, CustomerFilter)
>                                                     orderby a.custno
>                                                     select a;
>
>
>not this "loosey-goosey, hey C# 3 has anonymous types that will get you in trouble" way:
>
>
>            var customers = from a in db.customers
>             where SqlMethods.Like(a.custno, CustomerFilter) || SqlMethods.Like(a.company, CustomerFilter)
>             orderby a.custno
>             select new { a.custno, a.company, a.phone, a.faxno };
>
>
>
>>You need to get away from var because it won't pass between classes.
>>
>>Either pass the whole record:
>>
>>
>>            IEnumerable<customer> customers = from a in db.customers
>>                            where SqlMethods.Like(a.custno,CustomerFilter) || SqlMethods.Like(a.company,CustomerFilter)
>>                            orderby a.custno
>>                            select a;
>>
>>
>>Or create a new class:
>>
>>
>>  public class dataitem
>>    {
>>    public int custno { get; set; }
>>    public string company { get; set; }
>>    public string phone { get; set; }
>>    public string faxno { get; set; }
>>
>>    public dataitem(int cno, string c, string p, string f)
>>      {
>>      custno = cno;
>>      company = c;
>>      phone = p;
>>      faxno = f;
>>      }
>>    }
>>
>>
>>And return it:
>>
>>
>>            IEnumerable<dataitem> customers = from a in db.customers
>>                            where SqlMethods.Like(a.custno,CustomerFilter) || SqlMethods.Like(a.company,CustomerFilter)
>>                            orderby a.custno
>>                            select new dataitem(a.custno, a.company, a.phone, a.faxno) ;
>>
Previous
Reply
Map
View

Click here to load this message in the networking platform