ServiceStack ORMLite how not to serialize a list

I do not know how to store the collection (Comments) in a separate table. By default, comments are serialized and stored in the SomeClass table as the Comments column.

[{Id: 0, CreateDate: 2013-09-12T14: 28: 37.0456202 + 02: 00, SomeClassID: 1, CommentText: "text-to-text",}]

Is it possible to save it in separate tables?

public class SomeClass { [AutoIncrement] public int Id { get; set; } public string Title { get; set; } List<Comment> comments = new List<Comment>(); public List<Comment> Comments { get { return comments; } set { comments = value; } } } public class Comment { [AutoIncrement] public int Id { get; set; } [References(typeof(SomeClass))] public int SomeClassID { get; set; } [StringLength(4000)] public string CommentText { get; set; } } 
+4
source share
1 answer

I do not think ORMLite supports serialization for multiple tables. 1 table = 1, so the comments will be stored as a Blob field in the SomeClass table.

If you need to save them in separate tables, you will need to save the comments separately and return a link to the foreign key to the identifier of the SomeClass table.

+2
source

Source: https://habr.com/ru/post/1502063/


All Articles