Linq 高级查询 例子

linq  asp.net     DBA群: 225982985
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
using System.IO;
using System.Text;
using System.Data;

namespace SJLERP
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            Dictionary<string, string> cityAndNum =
                Regex.Matches(City.data, @"[^\r].*?\r")
                .Cast<Match>()
                .Select(c => Regex.Replace(c.Value, @"\s", ""))
                .Aggregate(new Dictionary<string, string>(), (reval, item) =>
                {
                    if (Regex.IsMatch(item, @"[\u4e00-\u9fa5]+\d+"))
                    {
                        string word = Regex.Match(item, @"[\u4e00-\u9fa5]+").Value;
                        string num = Regex.Match(item, @"\d+").Value;
                        reval.Add(word, num);
                    }

                    return reval;
                });
            ADOHelper.ExecuteCommand("create table KaixuanTest ( city varchar(max),num varchar(max) ) ");
            cityAndNum.ToList().ForEach(c =>
            {
                string sql = string.Format(" insert KaixuanTest select '{0}','{1}'",c.Key,c.Value);
                ADOHelper.ExecuteCommand(sql);

            });
        }
    }
}






public class City
{

    public static string data
    {

        get
        {
            return @"       北京区号
                            北京 010 

                            天津区号
                            天津 022 

                            河北区号
                            石家庄 0311 
                            保定 0312 
                            张家口 0313 
                            承德 0314 
                            唐山 0315 
                            廊坊 0316 
                            沧州 0317 
                            衡水 0318 
                            邢台 0319 
                            邯郸 0310 
                            秦皇岛 0335  

                            山西区号
                            朔州 0349 
                            太原 0351 
                            大同 0352 
                            阳泉 0353 
                            晋中 0354 
                            长治 0355 
                            晋城 0356 
                            临汾 0357 
                            吕梁 0358 
                            运城 0359 
                            忻州 0350  

                            内蒙古区号
                            呼和浩特 0471 
                            包头 0472 
                            乌海 0473 
                            乌兰察布 0474 
                            通辽 0475 
                            赤峰 0476 
                            鄂尔多斯 0477 
                            巴彦淖尔 0478 
                            锡林郭勒盟 0479 
                            呼伦贝尔 0470 
                            兴安盟 0482 
                            阿拉善盟 0483 

                            辽宁区号
                            沈阳 024 
                            大连 0411 
                            鞍山 0412 
                            抚顺 0413 
                            本溪 0414 
                            丹东 0415 
                            锦州 0416 
                            营口 0417 
                            阜新 0418 
                            辽阳 0419 
                            铁岭 0410 
                            朝阳 0421 
                            盘锦 0427 
                            葫芦岛 0429  

                            吉林区号
                            长春 0431 
                            吉林 0432 
                            延边 0433 
                            四平 0434 
                            通化 0435 
                            白城 0436 
                            辽源 0437 
                            松原 0438 
                            白山 0439 
                            珲春 0440 


                            浙江区号
                            杭州 0571 
                            湖州 0572 
                            嘉兴 0573 
                            宁波 0574 
                            绍兴 0575 
                            台州 0576 
                            温州 0577 
                            丽水 0578 
                            金华 0579 
                            衢州 0570 
                            舟山 0580  

                            黑龙江区号
                            哈尔滨 0451 
                            齐齐哈尔 0452 
                            牡丹江 0453 
                            佳木斯 0454 
                            绥化 0455 
                            黑河 0456 
                            大兴安岭地区 0457 
                            伊春 0458 
                            大庆 0459 
                            七台河 0464 
                            鸡西 0467 
                            鹤岗 0468 
                            双鸭山 0469  

                            上海区号
                            上海 021 

                            江苏区号
                            南京 025 
                            镇江 0511 
                            苏州 0512 
                            南通 0513 
                            扬州 0514 
                            盐城 0515 
                            徐州 0516 
                            淮安 0517 
                            连云港 0518 
                            常州 0519 
                            无锡 0510 
                            泰州 0523 
                            宿迁 0527  

                            安徽区号
                            合肥 0551 
                            蚌埠 0552 
                            芜湖 0553 
                            淮南 0554 
                            马鞍山 0555 
                            安庆 0556 
                            宿州 0557 
                            阜阳 0558 
                            亳州 0558 
                            黄山 0559 
                            滁州 0550 
                            淮北 0561 
                            铜陵 0562 
                            宣城 0563 
                            六安 0564 
                            巢湖 0565 
                            池州 0566  

                            福建区号
                            福州 0591 
                            厦门 0592 
                            宁德 0593 
                            莆田 0594 
                            泉州 0595 
                            漳州 0596 
                            龙岩 0597 
                            三明 0598 
                            南平 0599 

                            江西区号
                            南昌 0791 
                            九江 0792 
                            上饶 0793 
                            抚州 0794 
                            宜春 0795 
                            吉安 0796 
                            赣州 0797 
                            景德镇 0798 
                            萍乡 0799 
                            新余 0790 
                            鹰潭 0701  

                            山东区号
                            济南 0531 
                            青岛 0532 
                            淄博 0533 
                            德州 0534 
                            烟台 0535 
                            潍坊 0536 
                            济宁 0537 
                            泰安 0538 
                            临沂 0539 
                            菏泽 0530 
                            滨州 0543 
                            东营 0546 
                            威海 0631 
                            枣庄 0632 
                            日照 0633 
                            莱芜 0634 
                            聊城 0635  

                            河南区号
                            郑州 0371 
                            安阳 0372 
                            新乡 0373 
                            许昌 0374 
                            平顶山 0375 
                            信阳 0376 
                            南阳 0377 
                            开封 0378 
                            洛阳 0379 
                            商丘 0370 
                            焦作 0391 
                            济源 0391 
                            鹤壁 0392 
                            濮阳 0393 
                            周口 0394 
                            漯河 0395 
                            驻马店 0396 
                            三门峡 0398  

                            湖北区号
                            武汉 027 
                            鄂州 0711 
                            孝感 0712 
                            黄冈 0713 
                            黄石 0714 
                            咸宁 0715 
                            荆州 0716 
                            宜昌 0717 
                            恩施土家族苗族自治州 0718 
                            十堰 0719 
                            襄樊 0710 
                            随州 0722 
                            荆门 0724 
                            江汉仙桃 0728 
                            天门 0728 
                            潜江 0728  

                            湖南区号
                            长沙 0731 
                            株洲 0731 
                            湘潭 0731 
                            株洲(曾用) 0732 
                            湘潭(曾用) 0733 
                            衡阳 0734 
                            郴州 0735 
                            常德 0736 
                            益阳 0737 
                            娄底 0738 
                            邵阳 0739 
                            岳阳 0730 
                            湘西土家族苗族自治州 0743 
                            张家界 0744 
                            怀化 0745 
                            永州 0746  

                            广东区号
                            广州 020 
                            江门 0750 
                            韶关 0751 
                            惠州 0752 
                            梅州 0753 
                            汕头 0754 
                            深圳 0755 
                            珠海 0756 
                            佛山 0757 
                            肇庆 0758 
                            湛江 0759 
                            中山 0760 
                            河源 0762 
                            清远 0763 
                            云浮 0766 
                            潮州 0768 
                            东莞 0769 
                            汕尾 0660 
                            阳江 0662 
                            揭阳 0663 
                            茂名 0668 

                            广西区号
                            南宁 0771 
                            崇左 0771 
                            柳州 0772 
                            来宾 0772 
                            桂林 0773 
                            梧州 0774 
                            贺州 0774 
                            贵港 0775 
                            玉林 0775 
                            百色 0776 
                            钦州 0777 
                            河池 0778 
                            北海 0779 
                            防城港 0770  

                            四川区号
                            成都 028 
                            攀枝花 0812 
                            自贡 0813 
                            绵阳 0816 
                            南充 0817 
                            达州 0818 
                            遂宁 0825 
                            广安 0826 
                            巴中 0827 
                            宜宾 0831 
                            内江 0832 
                            资阳 0832 
                            乐山 0833 
                            眉山 0833 
                            凉山彝族自治州 0834 
                            雅安 0835 
                            甘孜藏族自治州 0836 
                            阿坝藏族羌族自治州 0837 
                            德阳 0838 
                            广元 0839 
                            泸州 0830 

                            海南区号
                            海口市 0898 
                            三亚市 0898 
                            五指山市 0898 
                            琼海市 0898 
                            儋州市 0898 
                            文昌市 0898 
                            万宁市 0898 
                            东方市 0898 
                            澄迈县 0898 
                            定安县 0898 
                            屯昌县 0898 
                            临高县 0898 
                            白沙黎族自治县 0898 
                            昌江黎族自治县 0898 
                            乐东黎族自治县 0898 
                            陵水黎族自治县 0898 
                            保亭黎族苗族自治县 0898 
                            琼中黎族苗族自治县 0898 
                            西沙群岛 0898 
                            南沙群岛 0898 
                            中沙群岛 0898 
                            洋浦经济开发区 0898

                            重庆区号
                            重庆 023 

                            贵州区号
                            贵阳 0851 
                            遵义 0852 
                            安顺 0853 
                            黔南布依族苗族自治州 0854 
                            黔东南苗族侗族自治州 0855 
                            铜仁地区 0856 
                            毕节地区 0857 
                            六盘水 0858 
                            黔西南布依族苗族自治州 0859 

                            云南区号
                            昆明 0871 
                            大理白族自治州 0872 
                            红河哈尼族彝族自治州 0873 
                            曲靖 0874 
                            保山 0875 
                            文山壮族苗族自治州 0876 
                            玉溪 0877 
                            楚雄彝族自治州 0878 
                            思茅 0879 
                            昭通 0870 
                            临沧 0883 
                            怒江傈僳族自治州 0886 
                            迪庆藏族自治州 0887 
                            丽江 0888 
                            西双版纳傣族自治州 0691 
                            德宏傣族景颇族自治州 0692  

                            西藏区号
                            拉萨 0891 
                            日喀则地区 0892 
                            山南地区 0893 
                            林芝地区 0894 
                            昌都地区 0895 
                            那曲地区 0896 
                            阿里地区 0897  

                            陕西区号
                            西安 029 
                            延安 0911 
                            榆林 0912 
                            渭南 0913 
                            商洛 0914 
                            安康 0915 
                            汉中 0916 
                            宝鸡 0917 
                            铜川 0919 

                            甘肃区号
                            兰州 0931 
                            定西 0932 
                            平凉 0933 
                            庆阳 0934 
                            武威 0935 
                            金昌 0935 
                            张掖 0936 
                            酒泉 0937 
                            嘉峪关 0937 
                            天水 0938 
                            陇南 0939 
                            临夏回族自治州 0930 
                            甘南藏族自治州 0941 
                            白银 0943  

                            青海区号
                            西宁 0971 
                            海东地区 0972 
                            黄南藏族自治州 0973 
                            海南藏族自治州 0974 
                            果洛藏族自治州 0975 
                            玉树藏族自治州 0976 
                            海西蒙古族藏族自治州德令哈 0977 
                            海西蒙古族藏族自治州格尔木 0979 
                            海北藏族自治州 0970 

                            宁夏区号
                            银川 0951
                            石嘴山 0952
                            吴忠 0953
                            固原 0954
                            中卫 0955

                            新疆区号
                            乌鲁木齐 0991
                            伊犁哈萨克自治州奎屯 0992
                            石河子 0993
                            昌吉回族自治州 0994
                            吐鲁番地区 0995
                            巴音郭楞蒙古自治州 0996
                            阿克苏地区 0997
                            喀什地区 0998
                            伊犁哈萨克自治州伊宁 0999
                            克拉玛依 0990
                            塔城地区 0901
                            哈密地区 0902
                            和田地区 0903
                            阿勒泰地区 0906
                            克孜勒苏柯尔克孜自治州 0908
                            博尔塔拉蒙古自治州 0909";
            return data;

        }

    }
} 本文来自: http://www.52mvc.com/showtopic-641.aspx
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值