.NET C# models to Knockout.js scaffolding
I'd like to have a scaffold that would create my empty knockout client
models for me so I don't have to write them. This can be done at design
time to fit my needs. I do use the knockout.mapping.js plug-in but I
really need an empty model definition on the client side and the mapping
plugin doesn't really help me with this.
Does anyone know if such a scaffold exists for Visual Studio? This would
save me a lot of time if it did.
Just for clarity I'm looking that could take something like this C#
public class DocumentClient
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long DocumentClientId { get; set; }
public virtual long DocumentId { get; set; }
[ForeignKey("DocumentId")]
[JsonIgnore]
public Document Document { get; set; }
public long ClientId { get; set; }
[ForeignKey("ClientId")]
[JsonIgnore]
public virtual Client Client { get; set; }
public ClientRole ClientRole { get; set; }
}
and turn it into this knockout out model
function DocumentClient(documentId, clientId, clientRole) {
var self = this;
self.DocumentId = ko.observable(documentId);
self.ClientId = ko.observable(clientId);
self.ClientRole = ko.observable(clientRole);
}
Found this just today. Take a look at my repo using T4 templates to generate exactly what you're speaking about
ReplyDeletehttps://github.com/zewa666/KO-CRUD