asp.net mvc - I want to insert unique value in my MVC using Entity Framework.I have looked all the answer available in stackoverflow, But still i cant get. -
please 1 provide me complete tutorial insert unique value in database.if duplicate data tried insert should show error message. please provide me complete tutorials because beginner
using linq
your_context_db context = new your_context_db(); public bool function(your_entity entity) { if(context.entity.where(x => x.id == entity.id).count() > 0) { return true; //the value has been existed. } else return false; //the value has not been existed. }
Comments
Post a Comment