zoukankan      html  css  js  c++  java
  • Nhibernate HQL 匿名类(严格说是map的使用以及构造函数的使用

    1.map的使用
    
    var hql=string.Format(@"select new map(
    tc.LimitIndexType as LimitIndexType,
    tc.LimitScope as LimitScope,
    tb.Id as Id
    )
    from BasLimitConfig tb,BasProductGroup ta ,BasLimitType tc 
    where tb.LimitDim1Id =ta.Id and tb.LimitDim2Id = tc.Id
    ");
    
    //这个是我框架的封装其实就是session.CreateQuery
    var list2 = Dao.FindList<object>(info);
    
    foreach (System.Collections.Hashtable entityObj in list2)
    {
    var oField = entityObj.GetEnumerator();
    while (oField.MoveNext())
    {
    string keyName = oField.Key.ToString();
    object keyValue = oField.Value;
    }
    }
    
    2.构造函数的使用
    
    var hql= string.Format(@"select new BasLimitConfig(tc.LimitIndexType,tc.LimitScope,tb)
    
    from BasLimitConfig tb,BasProductGroup ta ,BasLimitType tc 
    where tb.LimitDim1Id =ta.Id and tb.LimitDim2Id = tc.Id
    ");
    
    实体的构造函数如下(非缺省)
    
    public BasLimitConfig(int limitIndexType,int limitScore,BasLimitConfig b)
    {
    
    LimitIndexType = limitIndexType;
    LimitScope = limitScore;
    LimitConditionId = b.LimitConditionId;
    LimitTypeId = b.LimitTypeId;
    LimitTypeName = b.LimitTypeName;
    LimitDim1Id = b.LimitDim1Id;
    LimitDim1Value = b.LimitDim1Value;
    LimitDim2Id = b.LimitDim2Id;
    LimitDim2Value = b.LimitDim2Value;
    LowerLimitValue = b.LowerLimitValue;
    YellowLimitValue = b.YellowLimitValue;
    RedLimitValue = b.RedLimitValue;
    UpperLimitValue = b.UpperLimitValue;
    TotalAmount = b.TotalAmount;
    ActualIsAmount = b.ActualIsAmount;
    PartIsAmount = b.PartIsAmount;
    LimitBundleName = b.LimitBundleName;
    Type = b.Type;
    ProType = b.ProType;
    BusiType = b.BusiType;
    LimitType = b.LimitType;
    LimitObjectType = b.LimitObjectType;
    Limit1FullLevel = b.Limit1FullLevel;
    Limit2FullLevel = b.Limit2FullLevel;
    QuotaUsage = b.QuotaUsage;
    }
    
    //框架的封装内部调用 session.CreateQuery
    var quotaList = Holworth.Utility.HraUtility.ListToT<BasLimitConfig>(Dao.FindList(treeInfo));
    

      

  • 相关阅读:
    批量替换文本的工具
    wcf异常显示错误到客户端
    文件以二进制存入数据库和从数据库读取二进制文件
    关于关系数据库的范式
    对于挑战书上的很久之前都看不懂的DP看懂的突破
    操作系统概念
    关于P,V操作理解的突破,关于并发设计与并行
    关于快速沃尔什变换
    我觉得我应该养成经常翻收藏夹的习惯
    目前我的思考模式
  • 原文地址:https://www.cnblogs.com/kexb/p/5507241.html
Copyright © 2011-2022 走看看