I have an integer column in my table in the database, and I want to select it but it give me exception that can’t convert from int to string
Example I want to select CategoryID from Category table where CategoryName="Cat"
categoryID is int & categoryName is string
my linq query which I tried
string Category_ID = (from p in StaticVa.new_data_context.Categories
where p.CategoryName == Category_Name
select p.CategoryID).ToString();
It returned "SELECT [t0].[CategoryID]\r\nFROM [dbo].[Category] AS [t0]\r\nWHERE [t0].[CategoryName] = @p0\r\n"
try
LINQ is trying to return a IQueryable of every id which matches the where clause, if you only want one you need to specify it as single or first