简体   繁体   中英

.net core Angular SPA application : How to design a class in C# to accommodate generic data binding at api side?

We have a situation where the user performs some action on UI. Let's say selecting data from the drop-down. So according to selection the object being sent to Server side is going to change.

I have to keep only one controller API that will be called after value selection in the drop-down.

In future new items can be added to drop-down which in turn require Creation of new class at server side.

And properties in each class will be different.

How do I design the class at server side and client side to accommodate this generic change?

Is it optimal solution to send json string from client side and DE-serialize it in api to create the object of class?

Go take a look at this project, its the sample that microsoft use as a training aid and follows all the best practices. https://github.com/dotnet-architecture/eShopOnWeb Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM