• 1401/01/06

cutomerRepository error :

سلام من همه کار هایی که گفتین رو کردم 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

  • 1401/01/06
  • ساعت 18:36

این عبارت جزو 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

 

 


  • 1401/01/06
  • ساعت 18:54

سلام وقتتون بخیر 

داخل کلاس UnitOfWork که پیاده سازی کردین مطمئن بشید پراپرتی CustomerRepository وجود داشته باشه یا اگه

 وجود داره مطمئن بشید سطح دسترسی public داره


  • 1401/01/06
  • ساعت 19:45
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();
        }

  • 1401/01/06
  • ساعت 20:44

ممکنه به خاطر 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


  • 1401/01/06
  • ساعت 21:45

تایپ پراپرتیتون درست نیست باید از  ICustomerRepository استفاده کنید از کد زیر استفاده کنید

 public ICustomerRepository CustomersRepository
        {
            get
            {
                if(_customerRepository == null)
                {
                    _customerRepository = new CustomerRepository(db);
                }

                return _customerRepository;
            }
           
        }

  • 1401/01/06
  • ساعت 22:17

من کد شمارو جایگذاری ک کردم زیر 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

 

 


  • 1401/01/07
  • ساعت 01:57

internal کلاس UnitOfWork رو به public تبدیل کنید


  • 1401/01/07
  • ساعت 02:43
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

 


  • 1401/01/07
  • ساعت 02:49

سطح دسترسی ICustomersRepository  و CustomersRepository  رو چک کنید هردو باید public باشه 

در مورد ارور دوم هم میگه که UnitOfWork دوجا استفاده شده کدوم رو یوزینگ کنم یه دونش مربوط به پروژه خودتونه یکیش هم تو فضای نامیه که تو ارور گفته دوتا راه دارین یکی کلاس UnitOfWork که ساختین اسمش رو عوض کنید و راه بعدی هم فضای نامی که تو ارور گفته شده رو پاک کنید و از فضای نام کلاس UnitOfWork خودتون استفاده کنید


  • 1401/01/07
  • ساعت 12:57

خیلی ممنون


  • 1401/01/07
  • ساعت 13:49

خواهش میکنم دوست عزیز موفق باشید


logo-enamadlogo-samandehi