Retrieve an object from entityframework without ONE field

后端 未结 8 2359
[愿得一人]
[愿得一人] 2020-11-30 02:54

I\'m using entity framework to connect with the database. I\'ve one little problem:

I\'ve one table which have one varbinary(MAX) column(with filestream).

I\

8条回答
  •  醉话见心
    2020-11-30 03:38

    I tried this:

    From the edmx diagram (EF 6), I clicked the column I wanted to hide from EF and on their properties you can set their getter and setter to private. That way, for me it works.

    I return some data which includes a User reference, so I wanted to hide the Password field even though it's encrypted and salted, I just didn't want it on my json, and I didn't want to do a:

    Select(col => new {}) 
    

    because that's a pain to create and maintain, especially for big tables with a lot of relationships.

    The downside with this method is that if you ever regenerate your model, you would need to modify their getter and setter again.

提交回复
热议问题