Want to build the ChatGPT based Apps? Start here
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Mouhssine tahri
1.9k
201
6.4k
(Group)Join if you can't use the ICollection
Oct 27 2020 4:49 AM
Hi,
I have 2 table :(User and Service) with relation many to many
the EF create third table ServiceUserDiff
public
partial
class
User
{
public
int
UserID {
get
;
set
; }
public
string
FirstName {
get
;
set
; }
public
string
LastName {
get
;
set
; }
public
virtual
ICollection<ServiceUserDiff> UserDiffToService {
get
;
set
; }
}
public
partial
class
Service
{
public
int
CodeService {
get
;
set
; }
public
string
DesignationService {
get
;
set
; }
public
virtual
ICollection<ServiceUserDiff> ServiceToUserDiff {
get
;
set
; }
}
public
partial
class
ServiceUserDiff
{
public
Nullable<
int
> IdUserDiffService {
get
;
set
; }
public
Nullable<
int
> IdServiceUserDiff {
get
;
set
; }
public
Nullable<
int
> AttributaireON {
get
;
set
; }
public
int
IdDiff {
get
;
set
; }
public
virtual
Service ServiceDiff {
get
;
set
; }
public
virtual
User UserDiff {
get
;
set
; }
}
i create function to get information from 3 table
public
List<ServiceUserDiff> GetAllServiceUserDiff()
{
var listServiceUserDiff = bd.Service.GroupJoin(bd.ServiceUserDiff,
service => service.CodeService,
serviceUserDiff => serviceUserDiff.IdServiceUserDiff,
(service, serviceUserDiff) =>
new
{
serviceCode = service.CodeService,
serviceDsg = service.DesignationService,
user = serviceUserDiff.Join(bd.User,
serviceUserDiffs => serviceUserDiffs.IdUserDiffService,
user => user.UserID,
(user, serviceUserDiffs) =>
new
{
IdUser = serviceUserDiffs.UserID,
NameLast = serviceUserDiffs.LastName,
NameFirst = serviceUserDiffs.FirstName
}).ToList(),
});
return
listServiceUserDiff;
}
this function generates me the next error message:
Cannot implicitly convert type system linq IQueryable to system collections generic List
thanks for your help
Reply
Answers (
6
)
Why Can't I Get the Scoped Identity From EF After a Record is Saved?
crud operations using ajax in asp.netMvc Entity framework(code first)