hi all
im using entity framework 6.1.1 and code first And Use UnitOfWork
this is my unitofwork interface:
```
public interface IUnitOfWork
{
IDbSet<TEntity> Set<TEntity>() where TEntity : class;
}
```
this is my datacontext
```
public partial class myDataContext : DbContext, IDbContext
{
public new IDbSet<TEntity> Set<TEntity>() where TEntity : class
{
return base.Set<TEntity>();
}
1- public DbSet<ProductInventory> ProductInventories { get; set; }
2- public DbSet<ProductUnitDefain> ProductUnitDefains { get; set; }
}
```
this is Service Layer :
public readonly IDbSet<ProductUnitDefain> Entity;
im loading data with observablecollection and local metod for each model
```
public ObservableCollection<ProductUnitDefain> GetProductUnitDefainList(int product)
{
Entity.Where(x => product != null && x.Product == product).Load();
return new ObservableCollection<ProductUnitDefain>(Entity.Local);
}
public ObservableCollection<ProductInventory> GetProductInventoryList(int product)
{
Entity.Where(x => product != null && x.Product == product).Load();
return new ObservableCollection<ProductInventory>(Entity.Local);
}
```
i have 2 table in context:
ProductUnitDefain
and
ProductInventory
but exception error for ProductUnitDefain only
and ProductInventory worked perfectly
if table ProductUnitDefain is null
when Add Or Update record in to ProductUnitDefain exception nullreferenceexception in line:
return new ObservableCollection<ProductUnitDefain>(Entity.Local);
if ProductUnitDefain table have any record worked perfectly and no exception
how to resolve this problem
thanks
Comments: Hello, Could you please attach a small project which reproduces this issue? This would help us debug this further. Thanks
im using entity framework 6.1.1 and code first And Use UnitOfWork
this is my unitofwork interface:
```
public interface IUnitOfWork
{
IDbSet<TEntity> Set<TEntity>() where TEntity : class;
}
```
this is my datacontext
```
public partial class myDataContext : DbContext, IDbContext
{
public new IDbSet<TEntity> Set<TEntity>() where TEntity : class
{
return base.Set<TEntity>();
}
1- public DbSet<ProductInventory> ProductInventories { get; set; }
2- public DbSet<ProductUnitDefain> ProductUnitDefains { get; set; }
}
```
this is Service Layer :
public readonly IDbSet<ProductUnitDefain> Entity;
im loading data with observablecollection and local metod for each model
```
public ObservableCollection<ProductUnitDefain> GetProductUnitDefainList(int product)
{
Entity.Where(x => product != null && x.Product == product).Load();
return new ObservableCollection<ProductUnitDefain>(Entity.Local);
}
public ObservableCollection<ProductInventory> GetProductInventoryList(int product)
{
Entity.Where(x => product != null && x.Product == product).Load();
return new ObservableCollection<ProductInventory>(Entity.Local);
}
```
i have 2 table in context:
ProductUnitDefain
and
ProductInventory
but exception error for ProductUnitDefain only
and ProductInventory worked perfectly
if table ProductUnitDefain is null
when Add Or Update record in to ProductUnitDefain exception nullreferenceexception in line:
return new ObservableCollection<ProductUnitDefain>(Entity.Local);
if ProductUnitDefain table have any record worked perfectly and no exception
how to resolve this problem
thanks
Comments: Hello, Could you please attach a small project which reproduces this issue? This would help us debug this further. Thanks