I have a table named (BookNames) in an SQL Database with just one field named BookTitle which stores strings.
I need help writing a C# Function using LINQ which takes a string parameter and returns the ID of a record from that table that matches the string passed as a paremeter to this function.
I am using EntityFramework in my application and have a DBContext name BooksDBContext in my application.
So if my table with its data looks like as below:
1 War and Peace
2 A Farewell to Arms
And I pass a string (bookTitle "A Farewell to Arms") to the following function:
int MyFuntionToGetID (string bookTitle)
BooksDBContext context = new BooksDBContext();
This function should return me 2 which is the ID of the second record in this table.