a表
id
name
fidb表
fid
sid
bnameb_c表(关联)
rid
fidc表
rid
rnameC_d表(关联)
uid
ridd表
uid
uname
通过linq to sql怎么样查询出uid为指定值的a表中的内容?

解决方案 »

  1.   

    c.Where(x => x.rid == uid).SelectMany(x => b.Where(y => y.fid == x.rid)).SelectMany(x => a.Where(y => y.fid == x.fid))
      

  2.   

    我有个方法:public IList<a> GetList(guid uid)
    {
    }里头怎么写?
      

  3.   

    return c.Where(x => x.rid == uid).SelectMany(x => b.Where(y => y.fid == x.rid)).SelectMany(x => a.Where(y => y.fid == x.fid)).ToList();
    其中a b c代表你的数据源
      

  4.   

    a b c代表你的数据源代表哪个表的数据源?
      

  5.   

    public IList<a> GetList(guid uid)
    {
      var query= from x in db.a
                 let crids=db.C_d.Where(s=>s.d.uid==uid).Select(s=>s.c.rid)
                 let bfids=db.b_c.Where(t=>crids.Contains(t.c.rid)).Select(t=>t.b.fid)
                 where bfids.Contains(x.fid)
                 select x;
      return query.ToList();
    }
      

  6.   

    如果你是查找指定uname的记录,那才需要用到d表,否则你都有了uid了,还需要d表做什么?
      

  7.   

    对了,我是查询a表中的内容。 为什么 return c.where....放在前面?