Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Add objects to foregin table using Tag Helpers

$
0
0

I try add in one View element to two table Adventure and AdventureCategory. Tables are connected relation many-to-one

AdventureModel

publicclassAdventure{[Key]publicint idAdventure {get;set;}publicstring adventureName {get;set;}publicvirtualICollection<AdventureCategory>AdventureCategory{get;set;}}

AdventureCategoryModel

publicclassAdventureCategory{[Key]publicint idAdventureCategory {get;set;}[ForeignKey("Adventure")]publicint idAdventure {get;set;}publicstring categoryName {get;set;}publicvirtualAdventureAdventure{get;set;}}

In View i have many checkbox where i can choose few AdventureCategory

<input type="text" asp-for="adventureName"/>//field from Adventure table, it's ok<input type="checkbox"for="AdventureCategory.categoryName"value="swimming">//this return error "Element <ICollection>AdventureCategory does not contain a definition for adventureName"<input type="checkbox"for="AdventureCategory.categoryName"value="running">//this return error "Element <ICollection>AdventureCategory does not contain a definition for adventureName"<input type="checkbox"for="AdventureCategory.categoryName"value="walking">//this return error "Element <ICollection>AdventureCategory does not contain a definition for adventureName"

Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>