I have a couple checkbox on my Page.xaml page. I'm pulling data from the DB and I'd like it to be filtered based on what is checked. I'm passing a list of strings containing the content of the checkboxes that were checked. But I don't know how to pass the list to the query. Here's what I have:
Page.xaml.cs:
List<string> checks = new List<string>();
private void Button_Click(object sender, RoutedEventArgs e)
{
foreach (Control c in mainCanvas.Children)
{
if(c is CheckBox)
{
CheckBox chk = (CheckBox)c;
if(chk.IsChecked == true)
checks.Add(chk.Content.ToString());
}
}
ServiceReference1.Service1Client client =
new SmoothFusion.ServiceReference1.Service1Client();
client.GetPhotosCompleted += new EventHandler<SmoothFusion.ServiceReference1.GetPhotosCompletedEventArgs>(client_GetPhotosCompleted);
client.GetPhotosAsync();
}
void client_GetPhotosCompleted(object sender, SmoothFusion.ServiceReference1.GetPhotosCompletedEventArgs e)
{
listBox.ItemsSource = e.Result;
}
IService1.cs:
[ServiceContract]
public interface IService1
{
[OperationContract]
List<Pic> GetPhotos(List<string> checks);
}
Service1.svc.cs:
public class Service1 : IService1
{
#region IService1 Members
public List<Pic> GetPhotos(List<string> checks)
{
DataClasses1DataContext db = new DataClasses1DataContext();
var query = from attr in db.Attributes
where checks.Contains(attr.Attribute1)
select attr.AttributeID;
return query.ToList();
}
#endregion
}
The problem is that the query to pull the data is in the Web portion of my project, and the list of checkboxes is in the other part. So how can I pass my list?