Inserting a record with a TimeStamp field

Did anybody make it to insert an object with a TimeStamp field. When I try db.SubmitChanges() throws me: Argument types do not match. If I omit the timestamp field it works (however it won't protect me agains concurrency violations upon update or delete).
Here is my timestamp property definition:

protected System.Byte[] lastChange;

[Column(Storage="lastChange", Name="LastChange", AutoGen=true,
IsVersion=true)]
public System.Byte[] LastChange
{
   get { return lastChange; }
}

Interesting is that it works when reading from database (the timestamp is correctly read).


Answer this question

Inserting a record with a TimeStamp field

  • Klause

    Maybe you could try AutoGen=true & IsVerion=true

    IE;

    [Column(DBType="rowversion NOT NULL", IsVersion=true, AutoGen=true)]

    NOTE: After playing around with this i couldn't get it to work. I can't get columns with default values to work either.

     

     


  • Lenka

    Hi,

    It looks like SqlMetal generates wrong attribute header for TimeStamp columns.

    [Column(Storage="_Modified", DbType="rowversion NOT NULL", IsVersion=true)]

    If I change it to TimeStamp, it works.

    Daniel


  • leedt

    I find that this works:

    [Column(Storage="_Timestamp", DbType="timestamp NOT NULL", AutoGen=true)]



  • Vinod Sa

    The latest CTP is still the old one with only difference (AFAIK) that it is compiled against VS2005 RTM. Yesterday Dinesh stated (in public DLinq chat) that we can expect new CTP in spring.

  • hackfinn

    Looks like this is still broken in the lastest CTP if the column type is secified as rowversion instead of timestamp. Also, I couldn't get any server generated columns to work, e.g. the guid column. Dlinq would try to insert NULL into these columns which do not allow NULL values.



  • Guitz

    I tried it doesnt work. If anyone has tried something else that did work

    Thanks

    Anubhav


  • poum

     Mihies wrote:
    Did anybody make it to insert an object with a TimeStamp field. When I try db.SubmitChanges() throws me: Argument types do not match.


    So do I. I've got "Argument types do not match" exception many times but can't get further information about WHAT CAUSED that, stack trace does not show any useful information too.

    One more question: Where can I get DLINQ auto-generated SQL statements Before I call DataContext.SubmitChanges() I think it's vital for debugger like me :)

    Thanks.

  • Barry Neilsen

    There was a bug in the handling of the TimeStamp datatype, a fix for which was checked in.

    For logging, you should also be able to assign an output stream to DataContext.Log. For example: db.Log = Console.Out;



  • tjerk

    Miha,

    We are looking into this. It should work like server-generated columns.

    Thanks
    Dinesh Kulkarni
    Program Manager - The LINQ Project
    http://blogs.msdn.com/Dinesh.Kulkarni/

  • Inserting a record with a TimeStamp field