Ok can someone point out where I am going wrong here? I want to assign the results to a list and then assign that list to the itemsource of a grid....
public class AllLists
{
public static List<string> LstQteHeader = new List<string>();
}
using (var context = new AscentEntities())
{AllLists.LstQteHeader = (from d in context.Qte_Header select d);
}
}
}
DeanPosted Nov 15, 2013, 7:20 AM
VulpesPosted Nov 15, 2013, 7:03 AM
As you're assigning it to AllLists.LstQteHeader which is now of that type no conversions are necessary and it works fine :)
DeanPosted Nov 15, 2013, 6:57 AM
VulpesPosted Nov 15, 2013, 6:42 AM
DeanPosted Nov 15, 2013, 6:38 AM
Didn't have any errors until I run it, I then got:
'The invocation of the constructor on type 'Ascent_ERP.MainWindow' that matches the specified binding constraints threw an exception.' Line number '16' and line position '343'.
No clue what that means?
Thanks.
VulpesPosted Nov 15, 2013, 6:27 AM
You therefore need some way of providing a string representation of this object - either ToString() if the class overrides it, or by direct manipulation.
DeanPosted Nov 15, 2013, 6:23 AM
Error 1 Cannot implicitly convert type 'System.Collections.Generic.List
HanookPosted Nov 15, 2013, 6:17 AM
http://stackoverflow.com/questions/7488980/syntax-for-linq-query-to-liststring
http://stackoverflow.com/questions/2502586/linqtosql-query-to-return-liststring
VulpesPosted Nov 15, 2013, 6:16 AM
AllLists.LstQteHeader = (from d in context.Qte_Header select d.ToString()).ToList();
though no need to apply ToString() to d if it's already a string.
HanookPosted Nov 15, 2013, 6:14 AM
using (var context = new AscentEntities())
{AllLists.LstQteHeader = (from d in context.Qte_Header select d).ToList();
}