TextBlob properties aren't retrieved

Issue #51 resolved
Jeremy Kolb created an issue
    public class OperationalPointCollection : IOperationalGeometry
    {
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }

        public string Name { get; set; }

        public IMultiPoint Points { get; set; }

        [ManyToOne(CascadeOperations = CascadeOperation.CascadeRead)]
        public OperationalPointType PointType { get; set; }

        [ForeignKey(typeof(OperationalPointType))]
        public int OperationalPointTypeId { get; set; }

        [ManyToOne]
        public Operation Operation { get; set; }

        [ForeignKey(typeof(Operation))]
        public int OperationId { get; set; }

        [TextBlob("PointIdsBlobbed")]
        public List<string> PointIds { get; set; }

        public string PointIdsBlobbed { get; set; }
    }

I would expect the following to load PointIds but it does not:

connection.GetChild(this.CurrentOperation, o => o.OperationalPoints, true);

The workaround specified in http://forums.xamarin.com/discussion/4580/cross-platform-sqlite-orm doesn't work because of #50

Comments (11)

  1. Guillermo Gutiérrez

    I'll take a look. It should always load text-blobbed relationships regardless of the CascadeOperation parameter (that is always set to None). So I'll either fix #50 by adding a setter to the attribute or by always loading and writing textblobbed properties.

  2. Jeremy Kolb reporter

    I have to insert and then update immediately and then it works. For the store:

    var connection = this._connectionProviderService.Create();
                connection.RunInTransaction(() =>
                {
                    if (pointCollection.Id == 0)
                    {
                        connection.Insert(pointCollection);
    
                        // This is stupid but it's to workaround TextBlob properties
                        // not inserting with InsertWithChildren.
                        connection.UpdateWithChildren(pointCollection);
    
    Mvx.Resolve<IOperationsService>().Points.Add(pointCollection);
                    }
                    else
                        connection.UpdateWithChildren(pointCollection);
                });
    

    For retrieval I made a custom attribute:

        // Workaround for
        // https://bitbucket.org/twincoders/sqlite-net-extensions/issue/51/textblob-properties-arent-retrieved
        public class TextBlobCascadedAttribute : TextBlobAttribute
        {
            public TextBlobCascadedAttribute(string textProperty)
                : base(textProperty) {}
    
            public override CascadeOperation CascadeOperations
            {
                get { return CascadeOperation.All; }
            }
        }
    
  3. Log in to comment