简体   繁体   中英

Simple JOIN Syntax Not Working in Entity Framework

I am trying to add a join to an existing LINQ statement but my syntax is incorrect. I looked here for examples among other places yet, my construction is still not working. Visual Studio is throwing a hissy fit. Both datasets are in the context that I am trying to work with so not sure what I am doing wrong:

The red squiggly line under the "join" keyword produces the error "The type arguments cannot be inferred from the query" The "n" and "nc" aliases produce the error "Cannot resolve symbol"

在此处输入图片说明

My Original, working statement

 var query = from nc in context.NewClubs
                           where nc.ClubMasterCustomerId == clubMasterCustId
                           select nc;
               var results = query.Any();

What I am trying to do (Illustrated in SQL)

select nc.NewClubName,nc.Id from NewClub as nc
join NewClubBuilder ncb on ncb.NewClubId = nc.Id
where ncb.BuilderClubKeyNumber = 'K00841'

My translation from SQL to LINQ (Not working)

var query = from nc in context.NewClubs
            join n in context.NewClubBuilders on n.NewClubId equals nc.Id
            where nc.ClubMasterCustomerId == clubMasterCustId
            select nc;

            var results = query.Any();

Thanks

使用连接属性,因此nc.Id是第一个

join n in context.NewClubBuilders on nc.Id  equals n.NewClubId

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM