0


Asp.netMVCを使用しているリポジトリパターンを使用しています。BusinessLayerからこのリポジトリメソッドを呼び出しました。

public class Repository:IRepository
{
    private BIKESEntities context;

    public Repository(BIKESEntities context)
    {
        this.context = context;
    }

    public void Save<T>(T entity)
    {            
        context.AddObject("BIKEINFO", entity);
        context.SaveChanges();
    }
}

行中にエラーが発生します context.AddObject("BIKEINFO", entity);

4

1 に答える 1

1

これを試して。

context.AddObject(entity.GetType().Name, entity);

または、代わりに使用することもできます。

context.AddObject(typeof(T).Name, entity);

これはジェネリック型パラメーターを使用します。

于 2013-02-23T14:49:35.417 に答える