我正在处理 asp.net 应用程序,并且我创建了一个查询。我想更改它,以便如果选中复选框,则无法输入字段的空记录。我的查询如下所示:
var query = from d in context.data_vault.Where(d => states.Contains(d.STATE)
&& counties.Contains(d.COUNTY)
&& cities.Contains(d.CITY)
&& zipCodes.Contains(d.ZIP)
&& areaCodes.Contains(d.AREA_CODE)
&& (d.MKTVAL > Convert.ToInt32(txtMarketValueFrom) && d.MKTVAL < Convert.ToInt32(txtMarketValueTo.Text))
&& (d.LTV > Convert.ToByte(txtLTVFrom.Text ) && d.LTV < Convert.ToByte(txtLTVTo.Text))
&& d.FHA_LIMIT_FLAG == chkFHA.Checked
&& (d.MTGAMT > Convert.ToInt32(txtMortgageFrom.Text) && d.MTGAMT < Convert.ToInt32(txtMortgageTo.Text))
&& (d.MTGDATE > Convert.ToDateTime(txtMortgageDateFrom.Text) && d.MTGDATE < Convert.ToDateTime(txtMortgageDateTo.Text))
&& d.LOAN_TYPE == drpMortgageLoanType.Text
//&& (chkLenderName.Checked ) d.LENDERNAME != null
&& lenderNames.Contains(d.LENDERNAME)
//&& rdoexcludeSecondMortgage.Checked ? d.HE == "" : rdoexcludeSecondMortgage.Checked
//&& d.HEAMT = txtSecondMortgageFrom.Text
&& d.HE_LOAN_TYPE == drpSecondMortgageLoanType.SelectedItem.Text
&& d.HELENDERNAME == txtSecondMortgageLenderName.Text
&& (d.AGE > Convert.ToByte(txtAgeFrom.Text) && d.AGE < Convert.ToByte(txtAgeTo.Text)
//rdoNoPhone.Checked ? d.phones
))
group d by new
{
d.STATE
} into g
select new
{
g.Key.STATE,
Count = (Int32?)g.Sum(p => p.SCORE),
Phone = (Int64?)g.Count(p => p.PHONE != null)
};
GridView1.DataSource = query;
GridView1.DataBind();
如何更改它,以便如果选中 rdoNoPhone.Checked 单选按钮,则不包括具有空电话的记录