ADF BC composite ViewObject based on 3 entities - insert - oracle-adf

Is it possible to insert a ViewObject that is based on 3 entities? Or just view and update?
I created ViewObject that is based on 3 entities. All entities have foreign keys and associations between them. Selecting and updating this composite entity works fine. But insert doesn't. ADF version 11.1.2.3.0

When you created your VO, did you mark the second and third EOs you added as updateable?
Note that if the realtionship is 1 to many you might need to code what to do in an insert situation.
More on this here:
http://docs.oracle.com/cd/E35521_01/web.111230/e16182/bcadvvo.htm#CEGCAJCI
42.9 Creating a View Object with Multiple Updatable Entities

Related

Asp.Net core Deleting an entry from table in database: what is the outcome

I have a database with table Photos and table Categories. Each photo is related to one category by categoryId field.
What happens when I delete one category from Categories table? Will the photos with that category be updated with a null value in the categoryID? Or how will entity-framework react to this change?
Another question can I then reset with a mass-change the values of those categories in the photos table? And how can I do that?
hi if you have created relationship between table(using foreign key) then only the deletion of parent table will affect deletion of child table. if you just created table separately and managing relationship with your code then it will not affect the child table. if you are creating using model first approach in entity framework with specifying relation then relationship will be automatically created in backend.
their are four options available in sql on deletion of parent entity
1)No Action
2)Cascade
3)SET NULL
4)SET Default
to know how it will affect check this article
https://www.mssqltips.com/sqlservertip/2365/sql-server-foreign-key-update-and-delete-rules/
That would depend completely on how the ORM that is used defines the database model.
Assuming you use Entity Framework then you can define exactly how EF should react to that situation. In the DbContext you should find a OnModelCreating method in wich you can specify per table what restrictions you want on the table. There you can also define the behaviour of the OnDelete of a foreign key.
If you are not using EF but have your own or a different ORM then again, it depends on how that ORM is configured.
Simple check if you dont know about the used ORM is this: Does the field in the database have a foreign key and how is that configured? Also, is the field categoryID (as defined in the database) nullable? if so, then it apparently doesnt need the relation and shouldnt result in related deletes.

ADO.Net EF - how to define foreign key relation in model first approach?

I have been having previous issues regards to class inheritance and structuring a database around this and using the entity framework to no success. So I have tried to create the entities inside visual studio and see what database tables it creates automatically.
I have a Entity MediaItem which is Abstract and Game Inherits from this. Game has a Console (Int) which corresponds to ConsoleID. However, when I generate the database I get an extra unwanted column (ConsoleTypes_ConsoleID) inside MediaItems_Game table. Why is this and how can I prevent this from happening? Thanks.
First of all your model is probably wrong. ConsoleType and Game is not in one-to-one relation (unless you have single game for each console type). I expect 1 console can have multiple games. So it should be one-to-many. In reality game can be released on multiple platforms so it should be many-to-many.
You got unvanted column because your relation between ConsoleType and Game doesn't know that it should use Console property as a foreign key. This happens if you use independent association. Independent associations are used by default when you draw them from one entity to other entity in Entity designer. You must use foreign key association.
Start with this set up (draw association from ConsoleType to Game - you must have one-to-many relation):
Select relation between ConsoleType and Game an in properties click on Referential Constraint:
In Referential Constraint dialog just set up relation:
Save your model and generate database again.

Displaying fields from related tables in a Silverlight datagrid

I have a Silverlight 4.0 application that has a normalised database. In this database i have tables for Applicants, Licences, LicenceClasses, LicenceTypes and LicenceStatuses amongst others. The last 3 mentioned tables are lookup tables linked to the Licences table through foreign key relationships.I am using RIA services with the Entity Framework for data access. The scenario i am facing is as follows.
When i create a datagrid on my form i get all the appropriate colums with fields from the Licences table. I want to display the names from the lookup tables that are represented by the ID fields in the Licence table. I need to show for instance the LicenceStatus instead of the LicenceStatusID.
I have followed some examples about including the related collections in my domain service and making all the appropriate Include annotations in the Metadata classes. While i can correctly get this to work with one lookup field , i can't seem to find a way to include more than one look up table in my GetLicences query.
public IQueryable<LearnersLicence> GetLearnersLicences()
{
return this.ObjectContext.LearnersLicences.Include("LicenceClass");
}
In the above query i can only include the LicenceClass collection and i have found no way of including the LicenceStatus collection or multiple look up collections that i need to display.
How do i go about accomplishing this
You can include multiple tables by adding a include for each.
public IQueryable<LearnersLicence> GetLearnersLicences()
{
return this.ObjectContext.LearnersLicences.Include("LicenceClass").Include("LicenceTypes");
}

How can I model non-matching Foreign Keys

I'm trying to use EF to model an existing SQL database. The DB is multi-tenant by having a clientID column in every single table (I cannot change this). I have table structure like the following.
Table 'ItemID' columns:
ClientID (pk)
ItemID (pk)
ItemName
Table 'Items' columns:
ClientID (PK)
ItemID (PK) [FK to ItemID.ItemID]
Version (PK)
ItemAttribute1
ItemAttribute2
ItemAttribute3
The DB is designed to store previous versions (rows) of the 'Item' object, hence the 'Version' column and PK.
I am new to the EF and trying to adopt it for my project. However, it seems that EF cannot handle this situation very well. I am open to all ideas including using stored procedures or views instead of access tables directly from EF. What about getting rid of the PKs and using 'independant' relations instead?
One specific problem I ran into is that EF (at least the designer) requires all PKs in one table be mapped to all PK columns in any related table. This does not make sense to me, as the example I've given will never work given that constraint. I am trying to make Items inherit from ItemID. The error I get is:
Error 3003: Problem in mapping
fragments starting at line 170:All the
key properties (ItemID.ClientID,
ItemID.ItemID) of the EntitySet ItemID
must be mapped to all the key
properties (Items.ClientID,
Items.ItemID, Items.Version) of table
Items.
I have been looking up all I can find on this topic and nothing has answered these questions for me. I appreciate any help. Thanks.
The error that you are getting from your EDM is coming from the fact that EF supports inheritance only if both entities have the exact same primary keys (hence a one to one relationship on database) so you cannot have inheritance between these 2 entities according to the current schema.
However, I don't see a problem on having a One to Many association between ItemID and Items entities and I believe this is the default EF behavior when you update your model from the database.
Please have a look at this post for more info:
Entity Framework, TPT Inheritance

WCF RIA, Silverlight 4

I am working on a Silverlight 4 project. I am using WCF RIA on the server and expose the model using a DomainService. I have 2 tables, let's say Table1 and Table2 linked with Foreign key say FID.
Therefore, i can Load data from both table 1 and table 2 in single data grid.
But my question is while editing datagrid if i need to change foreign key's Link, let's say row 1 is linked to foreign key FID1 and I want to change that link to FID2. In same time i want change the content of table 2 in data grid on that row.
Example
datagrid1[ID1 Name Add FID1 F_post F_Name] => [ID1 Name Add FID2 F_post2 F_Name2]
Thanks
I don't see the problem ...
Have you used the automatically generated data source templates?
That should automatically set the linked object as something like a drop down list.

Resources