当from中有多个表时,而select 中只需要一个表中的所有数据,不必像sql一样用*,只要把类名写出来就行,摸索出来的经验,记下,希望对大家有帮助.

见下面查询,特别是加红部分.

       [DataObjectMethod(DataObjectMethodType.Select)]
        public static ZjcXueshenghuojiang[] List(int xuenian, int xueqi,long banjiId,long banjiStudentId)
        {
            //BaseBanjiStudent stu = new BaseBanjiStudent();
            //stu.BanjiStudentid

            string strHql = @"Select huojiang from ZjcXueshenghuojiang huojiang , BaseBanjiStudent stu ";
            strHql += " where huojiang.Xuenian = :xuenian and huojiang.Xueqi = :xueqi ";
            strHql += " and  huojiang.BanjiStudentId = stu.BanjiStudentid  and stu.BaseBanji.Banjiid = :banjiId ";
            //    strHql += " order by huojiang.StartDate DESC ";
            SimpleQuery query = new SimpleQuery(
                typeof(ZjcXueshenghuojiang), strHql);
            query.SetParameter("xuenian", xuenian);
            query.SetParameter("xueqi", xueqi);
            query.SetParameter("banjiId", banjiId);
            return (ZjcXueshenghuojiang[])ExecuteQuery(query);
        }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
猜你喜欢
  • 2021-11-02
  • 2022-12-23
  • 2021-04-03
  • 2022-12-23
  • 2021-11-12
相关资源
相似解决方案