问题描述
应该是很简单的。C#代码publicList<ProductTypeStatistics>GetCounts(DateTimestartDate,DateTimeendDate){List<ProductTypeStatistics>r=null;using(varcontext=newPCBContext()){r=context.Database.SqlQuery<ProductTypeStatistics>("sp_ProductTypeStatistics@startTime,@endTime",startDate,endDate).ToList();}returnr;}
存储过程代码ALTERProcedure[dbo].[sp_ProductTypeStatistics]@startTimeDateTime,@endTimeDateTimeASBEGINSELECTPT.Name,SUM(O.FinishCount)ASFinishCountFROMdbo.ProductTypeASPTINNERJOINdbo.[Order]ASOONPT.Id=O.ProductTypeIdWHERE(O.StartTimeBETWEEN@startTimeAND@endTime)GROUPBYPT.Name,O.ProductTypeIdEND
解决方案
解决方案二:
自己扩展EF执行sql的
时间: 2024-10-23 12:35:51