实体框架求和方法

时间:2015-10-03 08:48:36

标签: entity-framework sum entity

        var resultList = new DataTable();
        SqlConnection connection = new SqlConnection(@"server=. ; database=PersonnelTrackingSystem;Trusted_Connection=yes");
        connection.Open();
        SqlDataAdapter da = new SqlDataAdapter(@"SELECT sum(takePay) FROM [PersonnelTrackingSystem].[dbo].[personnelSallaries] ", connection);
        da.Fill(resultList);
        return resultList;

这是我的整数取薪变量之和的sql代码。我如何用实体框架改变它们? 我试过这样但是它不起作用

 PersonnelTrackingSystemEntities entity = new PersonnelTrackingSystemEntities();
        return (entity.personnelSallaries.Sum(d => d.takePay)).ToString().ToList();

0 个答案:

没有答案