1

我正在寻找一个支持 DynamicObject / IDynamicObjectMetaProvider 结构的微系统,例如:

public class VirtualTest : DynamicObject
{
    private readonly Dictionary<string, object> _properties = new Dictionary<string, object>();

    public object this[string propertyName]
    {
        get
        {
            return _properties[propertyName];
        }
        set
        {
            _properties[propertyName] = value;
        }
    }

    public override bool TryGetMember(GetMemberBinder binder, out object result)
    {
        return _properties.TryGetValue(binder.Name, out result);
    }

    public override bool TrySetMember(SetMemberBinder binder, object value)
    {
        _properties[binder.Name] = value;
        return true;
    }

}

填充:

var sessionFactory = Configure.Fluently()
            .ForMsSql2005Connection("TestDB", str, "System.Data.SqlClient").CreateSessionFactory();

using (var session = sessionFactory.OpenSession())
{
    using (var transaction = session.BeginTransaction())
    {
        var query = new SqlQuery("SELECT 1 AS TestField");
        var result = session.Fetch<VirtualTest>(query);
    }
}

它只是抛出一个MicroLiteException附加信息System.Object

MicroLite 是否支持此类对象?

4

0 回答 0