Get the Value of WPF Listview rows and compare them with database field using Linq query
i want to compare ECH_INTITULE in my database with the values of the listview rows but my problem is that i can't access the Listview items in my Linq query
here is my Xaml code for my Listview :
- <ListView x:Name="listView" SelectedItem="{Binding SelectedItem}" ItemsSource="{Binding}" DataContext="query" HorizontalAlignment="Left" Height="430" Margin="24,47,0,0" VerticalAlignment="Top" Width="940" >
- <ListView.View>
- <GridView x:Name="gridView">
- <GridViewColumn Header="Fournisseur" DisplayMemberBinding="{Binding fournisseur}" Width="280"/>
- <GridViewColumn Header ="Adresse Mail" DisplayMemberBinding="{Binding email}" Width="270"/>
- <GridViewColumn Header ="Date" DisplayMemberBinding="{Binding date}" Width="150"/>
- <GridViewColumn Header="Fichier CSV" DisplayMemberBinding="{Binding xxx}" Width="105"/>
- <GridViewColumn Header="Fichier PDF" DisplayMemberBinding="{Binding xxx}" Width="105"/>
- </GridView>
- </ListView.View>
- </ListView>
and here is my c# code : -
- CsvFileDescription outpCsvFileDescription = new CsvFileDescription
- {
- SeparatorChar = ',',
- FirstLineHasColumnNames = true
- };
-
- for (int i = 0; i < listView.Items.Count; i++)
- {
- var infoEcheances = from f in db.F_ECHEANCES
- //where f.ECH_Intitule == ???
- select new { f.ECH_Intitule, f.ECH_DateEch, f.CG_Num, f.ECH_Piece, f.ECH_RefPiece, f.ECH_Montant, f.ECH_Libelle };
-
-
- CsvContext cc = new CsvContext();
- string myPath = @"C:\Users\DefaultAccount\Desktop\Projet Top Of Travel\FichiersCSV\";
- string filename = string.Format("Facture{0}.csv", i);
- string finalPath = System.IO.Path.Combine(myPath, filename);
- cc.Write(infoEcheances, finalPath, outpCsvFileDescription);
- }