Click here to Skip to main content
15,889,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am using lambda expression to get object(Appointment) from database using its composite key (clinicId, Time, Date) but i don't know what to write

What I have tried:

i tried to write :
Appointment appointment = db.Appointments.Find(i => new {i.ClinicId, i.Date, i.Time,});

but an error appear:
Cannot convert lambda expression to type 'object[]' because it is not a delegate type

and i tried to write:
Appointment appointment = db.Appointments.Find(v => new MyClass { v.ClinicId, v.Time, v.Date });

where
private class MyClass {
            public TimeSpan Time { get; set; }
            public DateTime Date { get; set; }
            public int ClinicId { get; set; }
        } 

but the same error appear
thanks for your support
Posted
Updated 31-May-17 0:25am

I googled "entity framework find composite key" and this was the first result

c# - Finding an element in a DbSet with a composite primary key - Stack Overflow[^]

You can do the search yourself for more solutions
 
Share this answer
 
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900