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);
}
}
}

Hanook159 reputationPosted Nov 15, 2013, 1:14 AM EST
using (var context = new AscentEntities())
{AllLists.LstQteHeader = (from d in context.Qte_Header select d).ToList();
}
VulpesRank #55 · 29.2K reputationPosted Nov 15, 2013, 1:16 AM EST
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.
Hanook159 reputationPosted Nov 15, 2013, 1:17 AM EST
http://stackoverflow.com/questions/7488980/syntax-for-linq-query-to-liststring
http://stackoverflow.com/questions/2502586/linqtosql-query-to-return-liststring
Dean20 reputationPosted Nov 15, 2013, 1:23 AM EST
Error 1 Cannot implicitly convert type 'System.Collections.Generic.List
VulpesRank #55 · 29.2K reputationPosted Nov 15, 2013, 1:27 AM EST
You therefore need some way of providing a string representation of this object - either ToString() if the class overrides it, or by direct manipulation.
Dean20 reputationPosted Nov 15, 2013, 1:38 AM EST
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.
VulpesRank #55 · 29.2K reputationPosted Nov 15, 2013, 1:42 AM EST
Dean20 reputationPosted Nov 15, 2013, 1:57 AM EST
VulpesRank #55 · 29.2K reputationPosted Nov 15, 2013, 2:03 AM EST
As you're assigning it to AllLists.LstQteHeader which is now of that type no conversions are necessary and it works fine :)
Dean20 reputationPosted Nov 15, 2013, 2:20 AM EST