在我的應用程序中,我想爲導演分配電影。當然,沒有必要存儲重複的導演,所以我需要防止添加重複的行。 我記得有昔日樂趣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