I am trying to validate a unique combination of data in a table. I am using
devart Entity Framework.
I am trying to setup the validation on entity with Lightswitch as the application.
The Table I am checking for values already existing is: StuntDetails.
It has a foreign key for packageID and StuntId. I want to check that the
combination of PackageID and StuntID do not already exist in StuntDetails when
inserting. If it does, I want to raise an error.
In Entity Framework, it makes the foreign key and object linked to the parent table and for
referencing my PackageID I have to enter the entity Package.PackageId.
Can you please help me figure this out so it works correctly?
Here is what I have coded but I don't have the lambda code correct:
if (this.StuntDetails.Where(x => x.Package.PackageId == entity.Package.PackageId).FirstOrDefault() && x.Stunt.StuntId == entity.Stunt.StuntId).FirstOrDefault())
"This PackageId has already been entered for this Stunt. PackageId and StuntId must be unique for Stunt Detail.",