0
"어떤 속성 또는 필드 '색상'타입 '문자열'에 존재하지 않는다"나는 아래의 코드가 엔티티 프레임 워크 :가 어떻게 오류를 수정 할 동적 Linq에와 사용
private void ComboBox_DropDown(object sender, EventArgs e)
{
ComboBox cb1 = (ComboBox)sender;
string SelectField = cb1.Name.Substring(2);
var query = MyContext.Items.Select(SelectField);
foreach (ComboBox cb2 in gbFilters.Controls.OfType<ComboBox>().Where(com => com.Text != ""))
{
string propertyName = cb2.Name.Substring(2);
string propertyValue = cb2.Text;
query = query.Where(propertyName + "[email protected]", propertyValue);
}
var x = query;
x = x.Provider.CreateQuery(
Expression.Call(
typeof(Queryable), "Distinct",
new Type[] { x.ElementType },
x.Expression));
foreach (var y in x)
{
if (y != null)
cb1.Items.Add(y.ToString());
}
}
주요 초점은 foreach는 인을 일부. 다른 모든 것은 잘 작동하는 것 같습니다. 그러나 가치가있는 다른 드롭 다운을 사용하면 오류가 발생합니다. " 'String'유형의 속성이나 필드 'Color'가 없으며 Color는 ComboBox 이름으로 바꿀 수 있습니다. 콤보 cbColor
는 텍스트 White
을 가지고 내가 콤보 'cbType'에 드롭 다운을 수행하는 경우 동일하게
그래서 예에서 위의 코드가 될 것입니다 위 : 나는 오류가
var query = MyContext.Items.Select("Type");
query = query.Where("[email protected]", "White");
와 "No 재산권 또는 'Color'필드가 'String'유형에 있습니다. "
Doh! 고마워요. – user2125348