Fluent NHibernate to query stored procedure without an hbm.xml mapping

后端 未结 3 2006
感动是毒
感动是毒 2020-12-24 13:36

Is there any way to query stored procedure in Fluent Nhibernate without creating an hbm.xml file mapping?

3条回答
  •  借酒劲吻你
    2020-12-24 14:03

    You should have a class for returning result set in my case it's GameActivity class

    
    
        public class GameActivity
        {
                public virtual DateTime Date { get; set; }
                public virtual string GameRoundId { get; set; }
                public virtual int GameProvider { get; set; }
                public virtual string GameName { get; set; }
                public virtual decimal RealBet { get; set; }
                public virtual decimal RealWin { get; set; }
                public virtual decimal BonusBet { get; set; }
                public virtual decimal BonusWin { get; set; }
                public virtual decimal BonusContribution { get; set; }
                public virtual int IsRoundCompleted { get; set; }
                public virtual int IsRoundCancelled { get; set; }
        }
    
    

    Calling stored procedure "GetMemberGameActivity" to get the list

    
    
        var result = session.CreateSQLQuery("exec GetMemberGameActivity :mToken, :StartDate, :EndDate")
                            .SetResultTransformer(Transformers.AliasToBean())
                            .SetParameter("mToken", token)
                            .SetParameter("StartDate", startDate)
                            .SetParameter("EndDate", endDate)
                            .List().ToList();
    
    

提交回复
热议问题