I am working on MVC. I have scenario, where I am calling the action method from JQuery get method. My action method is returning object in JSON format. Below are my class properties,
Public Class Employee
Public Property ID As Integer
Public Property Name As String
Public Property PhoneNumber As Integer
Public Property FromDate As Date
Public Property ThruDate As Date? 'Nullable
Public Property Active As Boolean
Public Property Qty As Double? 'Nullable
End Class
What is best way to send object of Employee class to jquery.
- Should I create viewmodel with all the properties as string. convert employee entity into viewmodel and send that viewmodel object. But want to avoid this as every time I send data from client to server or vice-versa, I have to convert it to and from Employee object.
- Send the employee object directly with the properties as it is? If yes then again on client side, I have to convert the FromDate,ThruDate properties to Date object as their format changes to string.
- Any better approach then above?