سلام من همه کار هایی که گفتین رو کردم app.configرو هم اد کردم.
Severity Code Description Project File Line Suppression State
Error CS1061 'UnitOfWork' does not contain a definition for 'CustomerRepository' and no accessible extension method 'CustomerRepository' accepting a first argument of type 'UnitOfWork' could be found (are you missing a using directive or an assembly reference?) Accounting.App F:\c#\Accounting\Accounting.App\frm.cs 30 Active
این عبارت جزو using ها بود
using DevExpress.Xpo;
وقتی کامنتش میکنم این ارور رو میگیرم
Severity Code Description Project File Line Suppression State
Error CS0122 'UnitOfWork' is inaccessible due to its protection level Accounting.App F:\c#\Accounting\Accounting.App\frm.cs 28 Active
سلام وقتتون بخیر
داخل کلاس UnitOfWork که پیاده سازی کردین مطمئن بشید پراپرتی CustomerRepository وجود داشته باشه یا اگه
وجود داره مطمئن بشید سطح دسترسی public داره
internal class UnitOfWork:IDisposable
{
Accounting_DBEntities db = new Accounting_DBEntities();
private ICustomersRepository _customerRepository;
public CustomerRepository CustomersRepository
{
get
{
if(_customerRepository == null)
{
_customerRepository = new CustomerRepository(db);
}
return (CustomerRepository)_customerRepository;
}
}
public void Dispose()
{
db.Dispose();
}
ممکنه به خاطر internal باشع
وقتی پابلیکش میکنم این ارورارو میبینم
.Severity Code Description Project File Line Suppression State
Error CS0266 Cannot implicitly convert type 'Accounting.DataLayer.Repository.ICustomersRepository' to 'Accounting.DataLayer.Services.CustomerRepository'. An explicit conversion exists (are you missing a cast?) Accounting.DataLayer F:\c#\Accounting\Accounting.DataLayer\Context\UnitOfWork.cs 24 Active
----------------------------------------------
Severity Code Description Project File Line Suppression State
Error CS0053 Inconsistent accessibility: property type 'CustomerRepository' is less accessible than property 'UnitOfWork.CustomerRepository' Accounting.DataLayer F:\c#\Accounting\Accounting.DataLayer\Context\UnitOfWork.cs 16 Active
تایپ پراپرتیتون درست نیست باید از ICustomerRepository استفاده کنید از کد زیر استفاده کنید
public ICustomerRepository CustomersRepository
{
get
{
if(_customerRepository == null)
{
_customerRepository = new CustomerRepository(db);
}
return _customerRepository;
}
}
من کد شمارو جایگذاری ک کردم زیر CustomerRepository خط کشیده اینم ارورش ..
Severity Code Description Project File Line Suppression State
Error CS0053 Inconsistent accessibility: property type 'ICustomersRepository' is less accessible than property 'UnitOfWork.CustomersRepository' Accounting.DataLayer F:\c#\Accounting\Accounting.DataLayer\Context\UnitOfWork.cs 18 Active
internal کلاس UnitOfWork رو به public تبدیل کنید
namespace Accounting.DataLayer.Context
{
public class UnitOfWork:IDisposable
{
Accounting_DBEntities db = new Accounting_DBEntities();
private ICustomersRepository _customersRepository;
public ICustomersRepository CustomersRepository
{
get
{
if (_customersRepository == null)
{
_customersRepository = new CustomerRepository(db);
}
return _customersRepository;
}
}
public void Save()
{
db.SaveChanges();
}
public void Dispose()
{
db.Dispose();
}
}
}
تبدیل کردم این ارور رو برای CustomerRepository میگیرم
Severity Code Description Project File Line Suppression State
Error CS0053 Inconsistent accessibility: property type 'ICustomersRepository' is less accessible than property 'UnitOfWork.CustomersRepository' Accounting.DataLayer F:\c#\Accounting\Accounting.DataLayer\Context\UnitOfWork.cs 18 Active
این ارور رو هم وقتی از unitof work نمونه میسازم میگیرم توی frmCustomer
Severity Code Description Project File Line Suppression State
Error CS0104 'UnitOfWork' is an ambiguous reference between 'Accounting.DataLayer.Context.UnitOfWork' and 'DevExpress.Xpo.UnitOfWork' Accounting.App F:\c#\Accounting\Accounting.App\Customer\frm.cs 56 Active
سطح دسترسی ICustomersRepository و CustomersRepository رو چک کنید هردو باید public باشه
در مورد ارور دوم هم میگه که UnitOfWork دوجا استفاده شده کدوم رو یوزینگ کنم یه دونش مربوط به پروژه خودتونه یکیش هم تو فضای نامیه که تو ارور گفته دوتا راه دارین یکی کلاس UnitOfWork که ساختین اسمش رو عوض کنید و راه بعدی هم فضای نامی که تو ارور گفته شده رو پاک کنید و از فضای نام کلاس UnitOfWork خودتون استفاده کنید
خیلی ممنون
خواهش میکنم دوست عزیز موفق باشید