/// <summary> /// 订单视图类型数据 /// 多表复杂视图通过db实现如存储过程 /// </summary> /// <param name="id"></param> /// <returns></returns> public OrderView GetOrderView(string id) { var entityList = base.DataRepository.Get(@"SELECT A.ID, A.ProductId, B.ProductName, A.BuyAmount, A.BuyDate,A.BuyPerson,A.IsArrivaled,A.Notes,A.DiscountPercentage,A.ArrivaledDate FROM dbo.EPOrder A INNER JOIN dbo.EPProduct B ON A.ProductId = B.Id WHERE A.ID = @Id", new { ID = id }); var entity = entityList.FirstOrDefault <dynamic>(); var orderView = AutoMapperHelper <dynamic, OrderView> .AutoConvertDynamic(entity); return(orderView); }
/// <summary> /// 级联查询 /// </summary> /// <param name="id"></param> /// <returns></returns> public dynamic GetStudentScore(string id) { StringBuilder sb = new StringBuilder(); sb.Append("SELECT ROW_NUMBER() OVER(ORDER BY SC.SID) AS NUM, "); sb.Append("STU.SNAME, CO.CNAME, SC.SCORE "); sb.Append("FROM SC SC "); sb.Append("LEFT JOIN STUDENT STU "); sb.Append("ON SC.SID = STU.SID "); sb.Append("LEFT JOIN COURSE CO "); sb.Append("ON SC.CID = CO.CID "); sb.Append("WHERE SC.SID=@TMP_ID"); var data = DataRepository.GetList <dynamic>(sb.ToString(), new { TMP_ID = id }); return(AutoMapperHelper <dynamic, dynamic> .AutoConvertDynamic(data)); }