Alex
Alex

Reputation: 3968

Unable to initialise SqlParameter

I have the following code:

using System.Data.SqlClient;
using OPN.SP_Services.Interface;
using wwa.EPR.Services;

namespace OPN.SP_Services
{
    public class TestService : UnitOfWork<ClearviewLocalContext>, ITestService
    {
        public TestService(IDataContext<ClearviewLocalContext> dataContext) : base(dataContext)
        {

        }

        public void test()
        {
            var param = new SqlParameter();
        }
    }
}

namespace OPN.SP_Services.Interface
{
    public interface ITestService
    {
        void test();
    }
}

Dependency config:

container.Register<ITestService, TestService>();

called like this:

_testService.test();

When I step through the code and reach this line:

            var param = new SqlParameter();

and inspect the variable, I see the following in my locals:

enter image description here

Can anyone explain what is going on here?

Upvotes: 1

Views: 24

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1063338

All of the properties in red are internal properties, that don't work unless certain preconditions have been met. Usually, you'd never see them or access them out-of-order, precisely because they are internal. They are not required to be as well-behaved as public properties. That said: it isn't unusual for public properties to throw exceptions when accessed in an invalid state.

Basically: nothing to worry about here; no problems; business as normal. This is not the cause of whatever problem you are seeing elsewhere.

Upvotes: 1

Related Questions