속성 테이블과 PropertyImages 테이블이있는 부동산 사이트가 있습니다. 사용자가 그림을 업로드 할 때 PropertyImages에서 쿼리를 실행하려고합니다. 그 숫자를 picturename에 추가하십시오.Entity Framework에서 개수를 실행하는 방법
public IQueryable GetPictureCount()
{
int propertyId = Convert.ToInt16(ddlSelectProperty.SelectedValue);
var _db = new RESolution.Models.PropertyContext();
IQueryable query = _db.PropertyImages;
var mypic = (from c in _db.PropertyImages
where c.PropertyID == propertyId
select c).FirstOrDefault();
lblCount.Text = Convert.ToString(query);
}
는이 오류를 얻을 : "모든 코드 경로가 값을 돌려"다음과 같이
내 환경은 다음과 같습니다
VS Express 2013
Sql Express
win 8.1 development computer
"무효"나는 오류를 얻을 내가 IQuaryable 변경할 때
'lblCount.text = query.Count(). ToString();' System.Linq.IQueryable 내가 사용 지침을 찾았지만 발견 '카운트'에 대한 정의를 포함하지 않는 비
언급 dasblinkenlight으로
쿼리를 호출하고 결과를 인쇄 할 수 있습니다 lblCount.text = query.Count()를 ToString();. –
당신의 메소드는 ** Get ** PictureCount 라 불리고'IQueryable'을 반환한다고 선언 되었기 때문에 어딘가에'return' 문이 있어야합니다. 자신의 메소드를 부작용으로 사용한다면'IQueryable'을'void'로 대체하여 오류를 수정하십시오. – dasblinkenlight