working with two databases

Oct 25, 2007 at 10:51 AM

I use 2 databases, the first use default appConfig configuration (Sqlite in local)
and the second use (Mysql on network) like your sample

"DbContext ds = new DbContext(EntryConfig.GetDriver("MySql"));

if I use
"ds.ExecuteDataset ("INSERT INTO `documents` VALUES ("test","test");"
the data is save in the database (Mysql))

but if I use
"Document doc = Document.New("test", "test");"

the data is not saved
I don't understand how is the good code

"ds.Insert(doc);" and "doc.Save();" don't work also

Oct 25, 2007 at 5:36 PM
hello, i made several tests

my class "user" who has only one "HasOne" relation, function very well,
but the Document class who has several "HasOne" relations and one "HasMany" relation don't work.
the save code is :

Oct 26, 2007 at 2:44 AM
I test it and can't reproduce the situation you mentioned.

My app.config is:
<?xml version="1.0" encoding="utf-8" ?>
    <section name="Lephone.Settings" type="Lephone.Util.Setting.NameValueSectionHandler, Lephone.Util" />
    <add key="DataBase" value="@SQLite : @~Test.db" />
    <add key="DbProviderFactory" value="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
    <add key="MySql.DataBase" value="@MySql : server=localhost; user id=root; password=123; database=mytest; pooling=false" />
    <add key="MySql.DbProviderFactory" value="@SmartDbFactory : MySql.Data, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />

My test code is:
using System;
using System.Collections.Generic;
using Lephone.Data;
using Lephone.Data.Definition;
public abstract class User : DbObjectModel<User>
    public abstract Books Name { get; set; }
public abstract class MyTime : DbObjectModel<MyTime>
    public abstract Books Name { get; set; }
public abstract class Next : DbObjectModel<Next>
    public abstract Books Name { get; set; }
public abstract class Books : DbObjectModel<Books>
    public abstract string title { get; set; }
    public abstract string description { get; set; }
    public abstract DateTime buydate { get; set; }
    public abstract User nuser { get; set; }
    public abstract MyTime mtime { get; set; }
    public abstract IList<Next> xyz { get; set; }
    public Books()
    public Books(string title, string description, DateTime buydate)
        this.title = title;
        this.description = description;
        this.buydate = buydate;
class Program
    static void Main(string[] args)
        DbContext db = new DbContext("MySql");
        Books b = Books.New("tom", "cat", DateTime.Now);
There is little thing I want mentioned is when we define "HasMany" "HasAndBelongsToMany" fields with abstract property, the type of it should be "IList<T>", not "List<T>".

If you still have this issue, please make it as a small program to let me can reproduce it.
Oct 26, 2007 at 7:52 AM
I tested from your example
it was my code which was not good
I had forgotten a not null field which remained at null

I apologize to you have disturbed for nothing

thank you still