Click here to Skip to main content
15,347,117 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# to Mysql Login code Error Pin
Richard MacCutchan21-Mar-22 23:55
mveRichard MacCutchan21-Mar-22 23:55 
GeneralRe: C# to Mysql Login code Error Pin
N Mohamed rafi22-Mar-22 1:32
MemberN Mohamed rafi22-Mar-22 1:32 
GeneralRe: C# to Mysql Login code Error Pin
Dave Kreskowiak22-Mar-22 1:43
mveDave Kreskowiak22-Mar-22 1:43 
GeneralRe: C# to Mysql Login code Error Pin
N Mohamed rafi22-Mar-22 1:44
MemberN Mohamed rafi22-Mar-22 1:44 
GeneralRe: C# to Mysql Login code Error Pin
Dave Kreskowiak22-Mar-22 1:45
mveDave Kreskowiak22-Mar-22 1:45 
GeneralRe: C# to Mysql Login code Error Pin
N Mohamed rafi22-Mar-22 1:46
MemberN Mohamed rafi22-Mar-22 1:46 
GeneralRe: C# to Mysql Login code Error Pin
Dave Kreskowiak22-Mar-22 1:49
mveDave Kreskowiak22-Mar-22 1:49 
QuestionC# - managing JSON serialisation Pin
DerekT-P21-Mar-22 0:32
professionalDerekT-P21-Mar-22 0:32 
I have a multi-layer application (user interface, business objects, data access layers). The business objects are inter-related as you might expect, so a "Group" has a property that returns an array of "Users", and each User may have multiple "Events" and each Event can have multiple "Locations" for example. Ultimately the data is accessible via a website which makes extensive use of webservices to load data dynamically. All is well and good and when a webservice loads an Event it gets all that event's Locations returned in the auto-generated JSON. When the webservice returns a Group object it also returns the list of Users, and for each User all their Events, and for each Event all the Locations. Which very quickly gets unwieldy! Not only does it make the webservice response very large, but the database is hit very hard (most of the properties are "lazy loading" so, in the rest of the application, a group's Users are loaded only when explicitly referenced, but the JSON serialization accesses ALL the properties of Group, so...)

I can control this to an extent by decorating some properties with [ScriptIgnore] (which I had to do to break some circular references; e.g. the User object has a reference to its owning Group).

However what I really need is a way to customise which properties are included depending on the context. For some webservices, all I need is the top-level object (e.g. Group), but for others I need all the Users in that group as well. Sometimes I only need a small subset of the properties of Group.

I've looked at creating very simple classes that contain just the items I need, and creating a property in the main class that populates and returns that simple class, but that seems like a lot of effort for each use case. Is there any way to use custom attributes on the properties such that I can specify an attribute name at run time and have the serializer include only matching properties?
AnswerRe: C# - managing JSON serialisation Pin
Richard Deeming21-Mar-22 2:10
mveRichard Deeming21-Mar-22 2:10 
GeneralRe: C# - managing JSON serialisation Pin
DerekT-P21-Mar-22 3:21
professionalDerekT-P21-Mar-22 3:21 
GeneralRe: C# - managing JSON serialisation Pin
Richard Deeming21-Mar-22 3:28
mveRichard Deeming21-Mar-22 3:28 
AnswerRe: C# - managing JSON serialisation Pin
Gerry Schmitz21-Mar-22 4:59
mveGerry Schmitz21-Mar-22 4:59 
GeneralRe: C# - managing JSON serialisation Pin
DerekT-P21-Mar-22 7:26
professionalDerekT-P21-Mar-22 7:26 
AnswerRe: C# - managing JSON serialisation Pin
Eddy Vluggen21-Mar-22 7:02
professionalEddy Vluggen21-Mar-22 7:02 
GeneralRe: C# - managing JSON serialisation Pin
DerekT-P21-Mar-22 7:34
professionalDerekT-P21-Mar-22 7:34 
QuestionRe: C# - managing JSON serialisation Pin
Eddy Vluggen21-Mar-22 12:26
professionalEddy Vluggen21-Mar-22 12:26 
QuestionNeed C# and Mysql Tutorial Pin
N Mohamed rafi20-Mar-22 18:13
MemberN Mohamed rafi20-Mar-22 18:13 
AnswerRe: Need C# and Mysql Tutorial Pin
OriginalGriff20-Mar-22 20:43
mveOriginalGriff20-Mar-22 20:43 
AnswerRe: Need C# and Mysql Tutorial Pin
RobertSF21-Mar-22 10:29
professionalRobertSF21-Mar-22 10:29 
GeneralMysql Update Query Error Pin
N Mohamed rafi20-Mar-22 5:25
MemberN Mohamed rafi20-Mar-22 5:25 
GeneralRe: Mysql Update Query Error Pin
Victor Nijegorodov20-Mar-22 7:47
MemberVictor Nijegorodov20-Mar-22 7:47 
GeneralRe: Mysql Update Query Error Pin
N Mohamed rafi20-Mar-22 8:44
MemberN Mohamed rafi20-Mar-22 8:44 
SuggestionRe: Mysql Update Query Error Pin
Eddy Vluggen20-Mar-22 8:40
professionalEddy Vluggen20-Mar-22 8:40 
GeneralRe: Mysql Update Query Error Pin
N Mohamed rafi20-Mar-22 8:45
MemberN Mohamed rafi20-Mar-22 8:45 
GeneralRe: Mysql Update Query Error Pin
OriginalGriff20-Mar-22 8:47
mveOriginalGriff20-Mar-22 8:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.