I am looking for a way to pass the selected month from the date picker to my query in order to make the query dynamic. How do I replace the 9 with the month binded to the datepicker? I was thinking of something along the lines of a.sMonth = DateTime.Month(MDate)) but it doesn't work. Simple suggestions are more than welcome. Thank you!
PS: the sMonth from the table is long.
namespace Location.ViewModel
{
public class LocationViewModel: INotifyPropertyChanged
{
public LocationViewModel()
{
var db = new DailyEntities();
Efficiency = Convert.ToDecimal(db.LocationKPI.Where(a => a.sMonth == 9).Select(a => a.Efficiency).FirstOrDefault());
}
private DateTime _mDate = DateTime.Now;
public DateTime MDate
{
get { return _mDate; }
set { _mDate = value; OnPropertyChanged("MDate"); }
}
decimal efficiency;
public decimal Efficiency
{
get { return efficiency; }
set
{
efficiency = value;
OnPropertyChanged("Efficiency");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName = null)
{
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}