vendredi 15 novembre 2019

How to name anonymous type with string?

So, I have some JavaScript:

var myThing = { userId: dataItem.UserID, permissionID: dataItem.PermissionID };

What I'd like, however, is to have this in C#:

var userIdHtmlId = '@nameof(MyDto.UserID)';
var permissionIdHtmlId = '@nameof(MyDto.PermissionID)';

and then in JavaScript, somehow do something like this:

var userId = dataItem.GetValueByReflectionOrSomething(userIdHtmlId);
var permissionID = dataItem.GetValueByReflectionOrSomething(permissionIdHtmlId);
var myThing = { userId: userIdHtmlId, permissionID: permissionID };

...but have no idea how.

Is this possible? How?





Aucun commentaire:

Enregistrer un commentaire