User->Rolesの関係にあるEFモデルがあります。これは、データベース内の1対多の関係です。ロールのレコードからIDを選択し、ユーザーのレコードから名前を選択したいと思います。私が思いついたのは、1対1の関係のための作品です。動的言語クエリ内でリストを生成する方法がわかりません。多分SelectMany
?
ユーザーテーブル:ユーザー
結合テーブル:User_Role
役割表:役割
//does not select inside a collection of USER_ROLES
q= query.Select(" new ( ID, (new (USER_ROLES.ID as ID) as USER)")
//not valid
//q = query.Select(" new ( ID, (new List<Object> (USER_ROLES.ID as ID) as USER)") something I figure this would give me a list of User_Role's ID
//not valid
//q = query.Select(" new ( ID, (new List<Object> (USER_ROLES.ROLE.ID as ID) as USER)") something I figure this would give me a list of Role's ID
更新私は近づいています。selectmanyを使用しましたが、結果が重複しています
q = query.SelectMany("USER_ROLES","new (inner as myUSER,outer as myROLE) ").SelectD("new (myROLE.ID as ROLE_ID, new( myROLE.NAME, myUSER.USER.FIRSTNAME,myUSER.USER.ID)as user)")
結果は次のようになります。
Role->User_Role A-> User A
User_Role A-> User B ..notice the repeat of "User_Role A"
User_Role A-> User C
そのはず
Role->User Role a -> User A
+ User B
+ User C