can i use string field to uniquely identify the class?
Yes, you can.
I think there is problem, my class defined as :
type
[Entity]
[Table('Itms')]
[Id('Fcode', TIdGenerator.None)]
TItms = class
private
[Column('code', [TColumnProp.Required], 20)]
Fcode: string;
[Column('name', [], 50)]
Fname: Nullable<string>;
public
property code: string read Fcode write Fcode;
property name: Nullable<string> read Fname write Fname;
end;
for saving an object
FManager.SaveOrUpdate(itmGrp);
FManager.Flush;
Nothing saved in the database, but when i use integer ID (Primary key) all the data saved.
when i monitor the generated sql
with code :
FManager.SaveOrUpdate(itm);
I get :
UPDATE Itms SET
code = :A_code,
name = :A_name
WHERE code = :p_2;
A_code = "8888" (ftString)
A_name = "union air 18" (ftString)
p_2 = "8888" (ftString)
with code :
FManager.Save(itm);
I get
INSERT INTO Itms (
code, name)
VALUES (
:A_code, :A_name);
A_code = "8888" (ftString)
A_name = "union air 18" (ftString)
when i use integer primary key the code FManager.SaveOrUpdate(itm); generate correct sql, Is that Bug?
With generator none, you can't use SaveOrUpdate. You are passing an object with an Id to SaveOrUpdate method, Aurelius will try to update it (because there is an id) which will obviously fail because there isn't such record in database.
You must call explicitly Save or Update and it's up to you to decide which one is right (in this case, it's Save).