On 21 Apr., 16:12, Jonathan Pryor <[email protected]> wrote:
> OK, I *thought* I understood the original question...
>
> On Tue, 2010-04-20 at 07:44 -0700, mabu wrote:
> > i already got the code where the sequence is queried for the current
> > inserted value, but how do i set the correct
> > sequence name to get the correct value?
> > at the moment the sequence name is empty - so the sql breaks ... Can
> > you give me a hint please?
>
> mostly because I saw "Oracle" in the subject and thought "I have no idea
> about Oracle..."
>
> But now I'm really confused.  I thought you were referring to getting
> the primary keys from inserted rows, but you're referring to "sequence
> names."  What's a sequence name?  Does this have anything to do with
> e.g. Firebird's CREATE SEQUENCE statement?

Well the Sequence is an Entity that counts from x to n (normally 1
to .... ) and you can use this entity
to get an unique identifier in your tables - at sql server you create
an auto incremented int field for this purpose.

> On Tue, 2010-04-20 at 22:25 -0700, mabu wrote:
> > I Added to the DBML definition of the Column:
> > Expression="<SEQUENCE_NAME>.CURRVAL"

Just to note:
That statement is actually not correct - the correct has to be
<SEQUENCE_NAME>.NextVal ... You can have a look into
DbLinq.Oracle.OracleSqlProvider::GetInsertIds()

> This just seems terribly wrong.  You're editing the .dbml file to add
> a //Column/@Expression attribute that references the sequence name?

Yes .. So the correct ID is used at the Insert statement and the
correct ID is read from database after the insert and to update the
entity

> I have no idea what this would do.  (I'm not even sure
> what //Column/@Expression is supposed to do...)

It was just a try & error how i got the fieldname ... i do not know
exactly how i got it

> > The generated Identifier is the unique key and used to associate
> > children - do i have to update the children manually before the got
> > inserted into the database?

yes  and no .. i observe a funny behaviour at the moment. i have the
following structure:
Report [1] -> [n] Product [1] -> [n] Component [1] -> [n] Interface

Each Entity has a column ID that references at the specific child
entity.
The ID of report is automatically used at the insert of Product, but
all other IDs are not automatically used at their children to update
them. So the data breaks ...

Each ID-Column in the DBML is specified like:
<Column Name="ID" Type="System.Int32" IsDbGenerated="true"
IsPrimaryKey="true" AutoSync="OnInsert" CanBeNull="false"
UpdateCheck="Always"  Expression="S_INTERFACE.NextVal" />

> Some code might be needed so I can fully understand your scenario, but
> if you have something like:
>
>         Parent p = new Parent () {...};
>         db.Parents.InsertOnSubmit(p);
>         Child c1 = new Child() { Parent = p };
>         Child c2 = new Child() { Parent = p };
>         db.Children.InsertOnSubmit(c1);
>         db.Children.InsertOnSubmit(c2);
>         db.SubmitChanges();
>
> Once the Parent `p` is inserted within `db.SubmitChanges()`, it'll have
> a primary key.  The children don't need to be updated, as they're
> already referring to the `p` entity, and thus will have the appropriate
> foreign key id inserted.

Ok got it, but i obeserve following behaviour: i created 1 report with
150 products, 500 components and 900 interfaces.
they are created like in your example ... but when i call
Report.Products.Count the number 1 ... -> what?
I am still debugging but i am really confused at the moment...

> (Note, though, that `db.Parents.InsertOnSubmit()` MUST occur before the
> `db.Children.InsertOnSubmit()`, so that the parent exists before
> attempting to insert the children, as db.SubmitChanges() does the
> inserts/removes in the same order.)

yeah i already got this at debugging sessions - i am using an template
event to add the entities to the datacontext
and i had to synchronize these events ...


At the moment i do not know you to describe my error or how to debug
it ... i am really confused now


Martin

-- 
You received this message because you are subscribed to the Google Groups 
"DbLinq" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/dblinq?hl=en.

Reply via email to