在我的应用程序中,我想为导演分配电影。当然,没有必要存储重复的导演,所以我需要防止添加重复的行。 我记得有昔日乐趣sql server和该诀窍: 1. Get Director Id
1a. If director exist return existing director Id
1b. If director not exist add new and return add
想到这tipical 1对多relantionship: public class Parent
{
public int ID { get; set; }
public virtual List<Child> Children { get; set; }
}
public class Child
{
public int ID { get; set; }
我试图检索使用LINQ的加入,与在实体框架表中的特定类,其中条件如下: var result = (from a in db.Persons
join b in db.Person_IDs on a.PersonId equals b.PersonId
where b.FaceId == faceId
select new