Equal is not defined between type Nullable and Int32

前端 未结 2 1180
终归单人心
终归单人心 2021-01-27 03:46

I am writing a boring application to manage patients and their clinic history. I used SQLite combined with DbLinq libraries and DbMetal code generation utility. Here are two cla

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-27 04:22

    As I mentioned in the comment above (which I'm repeating here so I can link images), your primary key should not be nullable. There should be a property in your mapping that you can change to set it, although I don't use DbLinq, so I can't give you a screenshot of it directly. Instead, here it is in the LINQ-2-SQL DBML designer (left) and the Entity Framework EDMX designer (right).

    enter image description here enter image description here


    I'm not as sure about your deletion problem - that seems like it should work to me. Can you edit your question to include the whole block of your deletion code? As a preliminary guess, you're either creating a new object (instead of loading one) and then trying to delete it, or you're deleting the association without deleting the object.

    As a general rule, I never delete from a database when I can avoid it - I just mark inactive. It's much easier to "undelete" that way.

提交回复
热议问题