Marc Moineau

Marc Moineau

  • NA
  • 8
  • 489

C# with Linq not working

Dec 15 2020 7:44 PM
Good day All,
 
I'm new here I just started programming in C# not to long ago.
 
I'm building a little project connected to an SQL database and I'm not able to get the Result that I want I always get the length in the DataGrid.
 
I have a ComboBox with a listing. When selecting from the drop-down I take the Value and get the Partner_tb.PartnerKey from it. then I try to get a listing from the Document_tb based on the PartnerKey.
 
I always get 1 column with the length if I show the partnerKey.toString(). but the value should look like "MarcCyn"
Here's the code I have :
  1. public void partnerBox_SelectionChanged(object sender, SelectionChangedEventArgs e)  
  2. {  
  3. var partnerKey = from pn in dataContext.Partner_tbs  
  4. where pn.PartnerName == PartnerBox.SelectedValue.ToString()  
  5. select pn.PartnerKEY;  
  6. var documentName = from Document_tb in dataContext.Document_tbs  
  7. join Partner_tb in dataContext.Partner_tbs  
  8. on Document_tb.PartnerKEY equals Partner_tb.PartnerKEY  
  9. where Partner_tb.PartnerKEY == partnerKey.ToString()  
  10. select new { Document_tb.PartnerKEY, Document_tb.DocumentName, Document_tb.TransactionSetID, Document_tb.ControlNumber } ;  
  11. list997.ItemsSource = documentName;  
  12. }  
I would really appreciate any help on this.
 
Thanks in advance.
Marc

Answers (2)