3

I am trying to run custom query and I am using Entity framework, I tried this

string query = @"SELECT dm.DistrictName,sm.SchoolName,u.UserId,u.FirstName,u.LastName, sa.StudentId, sa.ReadingLevel
                 FROM  studentassessment sa
                 INNER JOIN assessmentmaster am ON sa.AssessmentId = am.AssessmentId
                 INNER JOIN studentclass sc ON sa.StudentId = sc.StudentId
                 INNER JOIN USER u ON sc.TeacherId = u.UserId
                 INNER JOIN schoolmaster sm ON u.SchoolCode = sm.SchoolCode
                 INNER JOIN  districtmaster dm ON sm.DistrictId = dm.DistrictId
                 WHERE u.RoleId = 5 && sa.GradeId = " + objParam.Grade + " && sa.AssessmentPeriodId = " + x.AssessmentPeriodId + " && dm.DistrictId = " + districtCode + " && am.DRAType = '" + objParam.LanguageType + "' && am.AssessmentTypeId = 1";



var dt = db.ExecuteStoreQuery<List<object>>(query).FirstOrDefault();

But didn't get succeed.

Is there any way to get results from ExecuteStoreQuery in the structure not mapped to any object type?

4

1 に答える 1

4

いいえ。EFExecuteStoreQueryには、クエリ結果セットの列と同じ名前のプロパティを持つデータ型 (クラス) が必要です。結果セットの特別なタイプを作成せずにクエリを実行する場合は、ADO.NET をSqlDataReader直接使用する必要があります。

于 2013-01-29T15:57:52.100 に答える