You are here

CLR types (schema) evolution

From version 4.1 Eloquera supports native type evolution.

Eloquera.config contains TypeUpdateAllowed tag that determines whether type changes shall be auto detected and applied.

<SmartRuntime Smart="true" TypeUpdateAllowed ="true" />

If TypeUpdateAllowed is turned on, while storing a new object, database will auto-detect

• Changes in field’s type. Already stored objects' fields will be converted to a new type.
• Newly added fields. Old objects will be converted to a new type, with new fields assigned a default value.
• Removed fields.

A function to rename type is also available

void RenameType(Type type, string oldTypeName);

Comments

marcusgreenwood
marcusgreenwood's picture
AWESOME!!!

Have been waiting for this for a long time and will allow us to move our product into production!
THANK YOU

billybraga
Can't wait to try this !!!

Can't wait to try this !!!

Now only missing displaying native objects in the DB studio...

billybraga
NICE !!! I just tried it...

NICE !!! I just tried it... it detected adding, removing AND RENAMING properties !!!

billybraga
On what criteria does

On what criteria does Eloquera base itself for the smart model change detection??? I am getting a problem when adding a field to a class. All the fields get shifted if they are all strings.

dmytro
dmytro's picture
Thanks! We will look into it

Thanks!
We will look into it

dmytro
dmytro's picture
Testing string evolution

Not sure that we can repeat the problem

#define FirstRunx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Eloquera.Client;
using System.Collections;
using System.Xml.XPath;
using System.Xml;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using Eloquera.Common;
using System.Globalization;

namespace Experiments
{

#if FirstRun
class A
    {
       public string s1;
       public string s2;
       public string s3;
    }
#else
class A
    {
       public string s1;
       public string new_s;
       public string s2;
       public string s3;
    }
#endif

    class Bug
    {

        static void Main(string[] args)
        {
            const string db_name = "OriginalDatabase";

            var db = new DB("server=(local);password=;options=none;");
#if FirstRun
            db.DeleteDatabase(db_name, true);
            db.CreateDatabase(db_name);
#endif
            db.OpenDatabase(db_name);
            db.RefreshMode = ObjectRefreshMode.AlwaysReturnUpdatedValues;

#if FirstRun
            A a = new A() { s1 = "s1", s2 = "s2", s3 = "s3"};
#else
            A a = new A() { s1 = "s1_n", new_s = "new_s", s2 = "s2_n", s3 = "s3_n"};
#endif
            db.Store(a);

            db.Close();

            db.OpenDatabase(db_name);

#if FirstRun
            var w = (A)db.ExecuteScalar("SELECT TOP 1 A");
            Assert.IsNotNull(w);
            Assert.AreEqual("s1", w.s1);
            Assert.AreEqual("s2", w.s2);
            Assert.AreEqual("s3", w.s3);

#else
            var w = (A)db.ExecuteScalar("SELECT TOP 1 A WHERE new_s = 'new_s'"); //new object
            Assert.IsNotNull(w);
            Assert.AreEqual("s1_n", w.s1);
            Assert.AreEqual("new_s", w.new_s);
            Assert.AreEqual("s2_n", w.s2);
            Assert.AreEqual("s3_n", w.s3);

            w = (A)db.ExecuteScalar("SELECT TOP 1 A WHERE s1 = 's1'"); //old object without new_s
            Assert.IsNotNull(w);
            Assert.AreEqual("s1", w.s1);
            Assert.AreEqual(null, w.new_s);
            Assert.AreEqual("s2", w.s2);
            Assert.AreEqual("s3", w.s3);

#endif

            db.Close();
        }
    }
}

Could you please send us your code sample that replicates the problem, you can send directly to support@eloquera.com

Copyright © 2008-2012 Eloquera Corp. All rights reserved.