asp.net - MVC3 check for references to model record before deletion -



asp.net - MVC3 check for references to model record before deletion -

what best practice checking if references particular model record exist before deleting record? basically, have model represents images, , metadata associated image. other models have references 1 or more images (depending on model).

let's example, have "item" has "mainimage" , "altimage", both of references image model. if delete item record, have check if 2 images referenced other item, or other table, , if not delete image. how go this?

since using database, allow maintain referential integrity using foreign key constraints on images. database or ef prevent deleting image if still beingness referenced. can grab exception , go on processing request without deleting image.

i found blog posting inferring foreign key constraints in ef may of utilize in setting these up.

asp.net asp.net-mvc-3

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -