Update not working

Update not working

Postby ashukr2013 » Tue 13 Aug 2013 13:53

Hi,

Not able to update the table which doesn't contain a primary key. Please tell me is it possible. Following is the table structure.

-- Create table
create table ECOMM_DBA.GPY_TK_TOKENCONFIG
(
MASKEDPAN_FIRSTDIGITS NUMBER(2),
MASKEDPAN_LASTDIGITS NUMBER(2),
VALIDATECARD_SHOPLOGIN VARCHAR2(30),
CUSTOMTOKEN_MINLENGTH NUMBER(2),
CUSTOMTOKEN_MAXLENGTH NUMBER(2),
CUSTOMTOKEN_MINDIGITS NUMBER(2),
CUSTOMTOKEN_MAXDIGITS NUMBER(2),
PREFIX_LENGTH NUMBER(2)
)

There are no primary keys. I am trying to do something like this.

using (BackOfficeEntitiesDataContext db = new BackOfficeEntitiesDataContext(DbHelper.GetConnectionString(dbAlias)))
{
var tokenConfig = db.GPYTKTOKENCONFIGs.FirstOrDefault();

tokenConfig.CUSTOMTOKENMAXDIGITS = tokenConfigViewModel.CustomTokenMaxDigits;
tokenConfig.CUSTOMTOKENMAXLENGTH = tokenConfigViewModel.CustomTokenMaxLength;
tokenConfig.CUSTOMTOKENMINDIGITS = tokenConfigViewModel.CustomTokenMinDigits;
tokenConfig.CUSTOMTOKENMINLENGTH = tokenConfigViewModel.CustomTokenMinLength;
tokenConfig.MASKEDPANFIRSTDIGITS = tokenConfigViewModel.MaskedPanFirstDigits;
tokenConfig.MASKEDPANLASTDIGITS = tokenConfigViewModel.MaskedPanLastDigits;
tokenConfig.PREFIXLENGTH = tokenConfigViewModel.PrefixLength;
tokenConfig.VALIDATECARDSHOPLOGIN = tokenConfigViewModel.ValidateShopLogin;

db.SubmitChanges(System.Data.Linq.ConflictMode.FailOnFirstConflict);
}
ashukr2013
 
Posts: 1
Joined: Tue 13 Aug 2013 13:46

Re: Update not working

Postby MariiaI » Wed 14 Aug 2013 13:00

Entity classes that don't have entity key are not recognized as an entities. Such entities cannot be cached and change tracking is not enabled for them. LinqConnect does not allow modifications of such entities - an exception is raised when such entity is created or deleted, and updates of such entity are ignored.
Please refer here http://www.devart.com/linqconnect/docs/ObjectIdentity.html

To avoid this situation, you could add a unique key to your table (in this case, the entity key for entity class is generated based on the unique not null key) or mark any property as an Entity key (it is sufficient to do this in the model only), and re-generate the code.
Also, there is another convenient way to solve it:
- add the Id property of the string type to your entity class;
- set the Entity Key value for it to True;
- set the Server Data Type and Source for it to ROWID;
- save the changes so that the code is regenerated.

More detailed information is available here(the topic is about Entity Framework support, but the principle of implementation is the same for LinqConnect).
Please notify us if this information helps.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to dotConnect for Oracle