开发者

NerdDinner difficulties

I'm having a problem with the Create method of the NerdDinner tutorial, which 开发者_如何学JAVAis very good BTW.

As you can see here http://nerddinnerbook.s3.amazonaws.com/Part5.htm in the Create method, he removed the ID field of the aspx page.

I did that too, but I cannot add any dinners because I get a primary key violation.

How is NerdDinner controlling the ids of each dinner? I revised the tutorial and could not see any references to identity fields on SQL database.

I even created a method to get me the highest id in the table:

    public int GetHighestDinnerId()
    {
        int resultado = (from dinner in dataContext.Dinners
                         select dinner.DinnerId).Max();
        return resultado;
    }

which does not work either.

Any thoughts?

Thank you


Heya, I'm just speculating here but I assume that the primary key should have the Auto-generated value property set to true so you don't have to explicitly set it, it gets generated for you on insert. You should be able to configure that within the dbml.

EDIT: Just looked through the NerdDinner tutorial and if you look at step 2, it talks about setting the ID column as an identity column so the value is auto-generated which is probably where you want to configure it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜