예제 #1
0
        public List <DtoRegion> GetRegionByIds(List <int> ids, RegionTypeEnum type)
        {
            string sql = @"  SELECT    cp.* ,
                                        d.Reg_ID AS DistrictId ,
                                        d.Reg_Name AS DistrictName
                              FROM(SELECT    c.Reg_ID AS CityId,
                                                    c.Reg_Name AS CityName,
                                                    p.Reg_ID AS ProvId,
                                                    p.Reg_Name AS ProvName
                                          FROM      Bas_Region c
                                                    INNER JOIN Bas_Region p ON c.Reg_ParentID = p.Reg_ID
                                        ) cp
                                       JOIN Bas_Region d ON cp.cityid = d.Reg_ParentID
                              WHERE 1=1 ";

            switch (type)
            {
            case RegionTypeEnum.省:
                sql += " AND cp.ProvId IN @Ids";
                break;

            case RegionTypeEnum.市:
                sql += " AND cp.CityId IN @Ids";
                break;

            case RegionTypeEnum.区:
                sql += " AND d.Reg_ID IN @Ids";
                break;

            default:
                return(null);
            }
            return(base.Query <DtoRegion>(sql, new { Ids = ids }).ToList());
        }
예제 #2
0
 /// <summary>
 /// 根据省市区获取地区所有信息(省市区)
 /// </summary>
 /// <param name="ids"></param>
 /// <returns></returns>
 public List <DtoRegion> GetRegionByIds(List <int> ids, RegionTypeEnum type)
 {
     return(RegionRepository.GetRegionByIds(ids, type));
 }