Working with a client that has a readonly database and a table that has no primary key. I am attempting to compare one table, "item" (has a primary) with "Pics" [No key] in order to get results from "item" that have pictures. Whether or not each item has a picture in "Pics". I cannot edit the databases themselves in SQL.
My ultimate goal is to return the results that only have pictures.
I've tried to use a raw SQL Query and then convert it to an IQueryable, however this does not allow me to search items using other parameters and is EXTREMELY slow. (there are probably 75+ columns in the "item" table and 10,000+ total items) I can only figure out how to use the query with 'SELECT *'.
Controller:
entities db = new entities();
var results = (from s in db.items
select s);
...
var Pics = db.Database.SqlQuery<Item>(
"SELECT * FROM dbo.Pics
AS p JOIN dbo.item
AS i ON
i.item = p.item
WHERE p.Pic = 'Yes'").AsQueryable();
...
results = Pics;
...
return View(results);
Try this
var results = from i in db.items
join p in db.Pics
on i.item equals p.item
where p.Pic == "Yes"
select i;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.