Insert takes to long

May 14, 2013 at 12:17 PM
Hello, I am using your orm to insert data received from a wcf server. I'm inserting about 10k entities and it takes a longer time then i expected 10min+.
the code is something like this :
foreach (ISentEntity transferEntity in ListTransferEntityes)
    MobileEntity mobileObj =  convertFromSentEntityToMobileEntity(transferEntity);
Are there any settings to the sqlcedatastore i can do to improve performance or another method of insert? I only have one reference made in the entities model and still without using references the speed doesn't improve much.
May 14, 2013 at 1:22 PM
Are you certain it's the Insert that's taking the time? How long does the convertFromSentEntityToMobileEntity call take?
May 28, 2013 at 11:15 AM
After cleaning up my code a bit i found the problem that takes the time. The time consuming part is when I make a select on the database to check for updates(trying to do an update or insert - if object exists update it if not insert it). The duration of the insert when i check for updates is somewhere between 5-10 times more.
May 28, 2013 at 1:28 PM
So the cost is likely in the Reflection work used to build the class and populate its Properties. Did you create your Entity classes manually, or with EntityGenerator? Did you create an ORM Creation Proxy method in the (Entity Generator will do that for you)? It is way faster if you have them.
May 28, 2013 at 1:34 PM
The classes where created manually following one of your examples like this:

entity class:

[Entity(KeyScheme.Identity, NameInStore = "GrupaProduse")]
public class GrupaProduse
    [Field(IsPrimaryKey = true, FieldName = "Id")]
    public Int64 id { get; set; }

    [Field(FieldName = "IdFirma")]
    public Int64 idFirma { get; set; }

    [Field(FieldName = "groupID")]
    public string groupID { get; set; }

    [Field(FieldName = "Nume")]
    public string nume { get; set; }

    [Field(FieldName = "IdAgent")]
    public Int64 idAgent { get; set; }

SqlCeDataStore class:

m_store = new SqlCeDataStore(Path.Combine(directory_path, "mobileDB.sdf"), "marketing");
        if (!m_store.StoreExists)
        m_store.ConnectionBehavior = ConnectionBehavior.Persistent;
        m_store.UseCommandCache = true;

And so on for all the entities. If u can give an example on what to change to improve the select performance I would much appreciate it.
May 29, 2013 at 1:57 PM
Also found another problem. I can't insert a datetime value in the db except for the default one(DefaultType = DefaultType.CurrentDateTime). If i change it to another field and do an interogation again it changes back to currentdatetime. If i don't set a default type it is set to 01/01/01
May 29, 2013 at 2:55 PM
What store type is this against? What platform?
May 29, 2013 at 3:38 PM
I updated my version to the latest one but i still can't insert DateTime in a SQLCE. I tried to set DataType=Dbtype.DateTime i tried withoud datatype or defaulttype and I still can't insert

[Field(FieldName = "Data")]
public DateTime dataRouting { get; set; }


[Field(FieldName = "Data", DefaultType = DefaultType.None)]
public DateTime dataRouting { get; set; }


[Field(FieldName = "Data", DataType=DbType.DateTime)]
public DateTime dataRouting { get; set; }

the date is set to 01/01/01 when i try to modify

when i set:

[Field(FieldName = "Data", DefaultType = DefaultType.CurrentDateTime)]
    public DateTime dataRouting { get; set; }
the date is set to current date when i try to modify
the initial object changes its datetime but when i do another select the date is reseted to the default
May 29, 2013 at 4:02 PM
I need some help with reproducing the DateTime issue. I just verified that this works:
public void DateTimeTest()

    var itemA = new TestItem("ItemA");

    var checkItem = m_store.Select<TestItem>().FirstOrDefault();
    Assert.AreEqual(itemA.TestDate, checkItem.TestDate);

    var now = DateTime.Now;

    itemA.TestDate = now;

    checkItem = m_store.Select<TestItem>().FirstOrDefault();
    Assert.AreEqual(itemA.TestDate.Second, checkItem.TestDate.Second);
May 29, 2013 at 4:19 PM
For your object creation speed issue, see the (new) documentation page here:
May 29, 2013 at 4:33 PM
Ok it seems my version didn't update so i check again and update it so everything works fine now. Sorry I disturbed you:P.