Hello,
Using DotConnect for Oracle with VS 2010 and EF4.
I need to use LINQ to make SELECT queries on a view. The view in Oracle does not have a primary key.
The edml absolutely needs a primary so I created a fake one in the store model and mapped a column on it. But when I do a "from q in this.getAll()" it is looking for the column in Oracle... but it is not there. Will I have to ask our DBA to create a useless primary column just because my application absolutely needs one??
Want to do a SELECT on a table without primary key
No, there is no need to create a new fake column.
There are several possibilities.
I recommend you to use Devart Entity model:
1. Drop the view onto the model designer, and Entity Key will be inferred over the NOT NULL columns.
2. Select both columns, and go to the Properties.
3. Set the Entity Key property to false for both columns (this makes the entity invalid), and drag these columns onto the model surface.
4. Select New Complex Type, and delete the view from the Model.Store node in Model Explorer. Here is the Complex Type.
5. Right-click the Model.Store node and choose the Add Command Text... option. Paste the following SQL:
Do not regenerate the Parameters collection, and don't obtain metadata.
6. Go to Properties of the generated procedure, and set the value of the Result Set Parameter Name property to cur.
7. Here is the code to call the procedure:
There are several possibilities.
I recommend you to use Devart Entity model:
1. Drop the view onto the model designer, and Entity Key will be inferred over the NOT NULL columns.
2. Select both columns, and go to the Properties.
3. Set the Entity Key property to false for both columns (this makes the entity invalid), and drag these columns onto the model surface.
4. Select New Complex Type, and delete the view from the Model.Store node in Model Explorer. Here is the Complex Type.
5. Right-click the Model.Store node and choose the Add Command Text... option. Paste the following SQL:
Code: Select all
declare cur sys_refcursor;
begin
open :cur for select * from ;
end;
6. Go to Properties of the generated procedure, and set the value of the Result Set Parameter Name property to cur.
7. Here is the code to call the procedure:
Code: Select all
using(ScottModel.ScottEntities db = new ScottModel.ScottEntities()) {
var q = db.Procedure1();
}