小编Ben*_*nni的帖子

流畅的NHibernate BinaryBlobType

今天我正在研究MySQL数据库,我不知道如何将字节[]映射到BLOB列...

我的表看起来像这样:

CREATE  TABLE `images` (
`Id` INT NOT NULL AUTO_INCREMENT ,
`imgText` VARCHAR(45) NULL ,
`image` BLOB NULL ,
 PRIMARY KEY (`Id`) );
Run Code Online (Sandbox Code Playgroud)

制图:

public class imagesMap : ClassMap<images> {
    public imagesMap() {
        Id(x => x.Id);
        Map(x => x.imgText);
        Map(x => x.image).CustomType<BinaryBlobType>();
    }
}
Run Code Online (Sandbox Code Playgroud)

Buisnessobject:

public class images {

    public virtual int Id{get;set;}
    public virtual string imgText{get;set;}
    public virtual Byte[] image{get;set;}
}
Run Code Online (Sandbox Code Playgroud)

如果我启动我的应用程序,我立即得到一个例外:

NHibernate.MappingException:无法实例化IType BinaryBlobType:System.MissingMethodException他说这个IType是"No Constructor defined"

我无法解释为什么它不起作用,每个人都告诉我,我只需要映射CustomType()

我很感激每一个帮助!

格雷茨,本尼

blob fluent-nhibernate

4
推荐指数
1
解决办法
5510
查看次数

C#对此对象的反思

我完全陷入了反思问题,我认为这不是很大,但我没有找到任何解决方案.

public class myClass : myClassIF {

    public myClass() { }

    private void doSomething_A() {
        //...
    }

    private void doSomething_B() {
        //...
    }

    public void DecideAndCall(string identifier) {
        string methodName = "doSomething_" + identifier;
        MethodInfo mi = this.GetType().GetMethod(methodName); //here i got a NullReference??
        //here should be the Invocation of the Method and so on...
    }
}
Run Code Online (Sandbox Code Playgroud)

界面看起来像这样:

public interface myClassIF {

    void DecideAndCall(string identifier);

}
Run Code Online (Sandbox Code Playgroud)

如果我调用GetMethod("...") - Method,我总是得到一个NullReference.我无法理解这一点,因为在这个项目的另一部分我以前做过这个.但是我在其他类型中使用Refelction而不是"this".

是否有可能在实际的instanciated对象中反映方法?我想我应该是,但我不知道怎么样......

非常感谢!奔奔

c# reflection

2
推荐指数
1
解决办法
440
查看次数

标签 统计

blob ×1

c# ×1

fluent-nhibernate ×1

reflection ×1