首页 > 代码库 > nhibernate记事

nhibernate记事

  • code mapping proc
  •     var result = session.CreateSQLQuery("exec GetMemberGameActivity :mToken, :StartDate, :EndDate")
                            .SetResultTransformer(Transformers.AliasToBean())
                            .SetParameter("mToken", token)
                            .SetParameter("StartDate", startDate)
                            .SetParameter("EndDate", endDate)
                            .List().ToList();
  • mysql  参数用 ? ,SetParameter可采用index方式赋值
  • 清除指定缓存
  • sessionFactory.Evict(typeof(Cat), catId); //evict a particular Cat
    sessionFactory.Evict(typeof(Cat)); //evict all Cats
    sessionFactory.EvictCollection("Eg.Cat.Kittens", catId); //evict a particular collection of kittens
    sessionFactory.EvictCollection("Eg.Cat.Kittens"); //evict all kitten collections

nhibernate记事