开发者

How to Select one element from a linq multiple join table?

var queryInfo = (from p in table1
                 join q in table2 on p.TABLEID equals q.USERNAME
                 join b in table3 on p.ORIGINAL_USER equals b.USERNAME
                 where p.NAME == IdVal
                 select new 
      开发者_运维百科                  { 
                            p.NAME,
                            p.ID,
                            p.EXCHANGE,
                            p.CREATION,
                            q.USERNAME,
                            q_email = q.EMAIL,
                            q_fullname = q.FULL_NAME,
                            b_email = b.EMAIL,
                            p.ORIGINAL_USER,
                            b_fullname = b.FULL_NAME
                        });

Name = queryInfo.ToList().ElementAt(0).ToString();
ID = queryInfo.ToList().ElementAt(1).ToString();
exchange = queryInfo.ToList().ElementAt(2).ToString();
Creation = queryInfo.ToList().ElementAt(3).ToString();
AUsername = queryInfo.ToList().ElementAt(4).ToString();
AEmail = queryInfo.ToList().ElementAt(5).ToString();
AFullName = queryInfo.ToList().ElementAt(6).ToString();
EEmail = queryInfo.ToList().ElementAt(7).ToString();
EUsername = queryInfo.ToList().ElementAt(8).ToString();
EFullName = queryInfo.ToList().ElementAt(9).ToString();

The query is correct and working, I'm having problem trying to select and assign one to each declared variable.

I tried

queryInfo.ToList().ElementAt(0).ToString();

but this is not working. What is the proper syntax?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜