var query = (from o in context.Customers
              select new{
                        o.uid,                                                                      
                        o.Phone }
                             ).Concat(
                             from n in context.Employees
                             select new { 
                                 n.uid,
                                 n.Phone
                             }
                             );
报错:
错误 14 “System.Linq.IQueryable<AnonymousType#1>”不包含“Concat”的定义,并且最佳扩展方法重载“System.Linq.ParallelEnumerable.Concat<TSource>(System.Linq.ParallelQuery<TSource>, System.Collections.Generic.IEnumerable<TSource>)”的某些参数无效

解决方案 »

  1.   

    var query = (from o in context.Customers
      select new temp{
      id=o.uid,   
      phone=o.Phone }
      ).Concat(
      from n in context.Employees
      selectnew temp{
      id=o.uid,   
      phone=o.Phone }
      );
    class temp
    {
      public int id{get;set;}
      public string phone {get;set;}
    }
      

  2.   

    var query = (from o in context.Customers
      select new temp{
      id=o.uid,   
      regionId = o.regionId; //??无法int?转换为int
      phone=o.Phone }
      ).Concat(
      from n in context.Employees
      selectnew temp{
      id=n.uid,   
      regionId= n.regionId///??
      phone=n.Phone }
      );
    class temp
    {
      public int id{get;set;}
    //---------------
      public int regionId{get;set;}  //
    //-------------------
      public string phone {get;set;}
    }
    ///=========
    regionId在数据库是定义是int的。
    无论我将temp的regionId 定义为int 还是Int32都报  无法int?转换为int
      

  3.   

    http://msdn.microsoft.com/zh-cn/library/bb351755.aspx
    多看看MSDN再玩这种语法糖。
      

  4.   

      regionId = o.regionId==null?0:int.parse(o.regionId)