Reputation: 1065
Suppose I have a modal pop open which is populated using ajax calls and javascript.
I have already written classes for my data objects in the backend which I'd like to use, which come from my database but for arguments sake are just dummy classes:
public class Foo {
public string Property1 { get;set; }
public string Property2 { get;set; }
}
public class Bar {
public int Id { get;set; }
public int Name { get;set; }
}
I need data from both of these objects already received from the database. I would like to know what the best approach is for returning them back to the client side. I have already come up with a few ideas:
For this particular example, I could work around it but I feel like this is going to come up a lot within what I am coding and I figured I'd ask before coming up with a solution. Anyone have any experience/feedback? If WCF helps me for this particular problem in any way, I'd definitely be willing to make the switch.
I am using jQuery if that makes a difference.
Upvotes: 1
Views: 92
Reputation: 8410
Please, create a wrapper class that includes the two class instances:
public class FooBar {
public Foo foo { get; set; }
public Bar bar { get; set; }
}
This makes sure that, at the client side:
At least, that is my opinion :-)
Upvotes: 2