Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sharing datamodel classes between client and server #47

Closed
asierpn opened this issue Jun 25, 2024 · 3 comments · Fixed by #92
Closed

Allow sharing datamodel classes between client and server #47

asierpn opened this issue Jun 25, 2024 · 3 comments · Fixed by #92
Labels
Client Improvements or additions to the client code
Milestone

Comments

@asierpn
Copy link

asierpn commented Jun 25, 2024

We have started to share datamodel classes between server and client in our project, but to make it work I had to change this method in the ServiceSerializer class because the Version column on the client side is now of type byte[] like on the server side:

        public static string GetVersion(JObject instance)
        {
            foreach (JProperty property in instance.Properties())
            {
                if (string.Equals(property.Name, SystemProperties.JsonVersionProperty, StringComparison.OrdinalIgnoreCase))
                {
                    return JsonConvert.SerializeObject(instance.Value<byte[]>(property.Name)).Replace("\"", "");
                }
            }
            return null;
        }

It would be great if the new version of the library allowed this, so that the same classes could be reused between server and client.

@asierpn asierpn added Feature Request Requires Triage This issue has not been checked by the project team. labels Jun 25, 2024
@adrianhall adrianhall added Client Improvements or additions to the client code and removed Requires Triage This issue has not been checked by the project team. labels Jul 11, 2024
@adrianhall adrianhall added this to the 8.0.0 milestone Jul 11, 2024
@adrianhall
Copy link
Collaborator

As an FYI - this should work - I need to add specific integration test suite.

However, even more so now than before, sharing models between client and server will be difficult because of differing requirements - indexing, SQLite vs. AzureSQL requirements, etc. all suggest that interfaces with two different implementations is the way to go.

@asierpn
Copy link
Author

asierpn commented Aug 27, 2024

Ok, I will keep this in mind, sharing data model classes between client and server saves us a lot of time, but at this point we are only sharing a small percentage of our entire model.

I will wait until the new library version is released to see if there are any problems with this approach in our project.

@adrianhall adrianhall modified the milestones: 8.0.0, 8.0.1 Aug 28, 2024
@adrianhall
Copy link
Collaborator

Deferring the testing of this until the 8.0.1 release so I can get the 8.0.0 beta release out today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client Improvements or additions to the client code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants