linq2db / docs

Documentation sources and build scripts
3 stars 10 forks source link

How to use DataConnectionExtensions.ExecuteProc()? #11

Open journger opened 5 years ago

journger commented 5 years ago

I am trying to get hang of linq2db, but can't find any real examples. for example I am trying to run a stored procedure (see below), however it does not seem to fire.

int x = DataConnectionExtensions.ExecuteProc(connection, "spName", DataParameter.Varchar("whateverParamName", "whateverParamValue")) I am passing the parameters the right way? Like sql, should it be EXEC spName @whateverParamName or is it ok When I specify dataparameter do I need to specify with @? like @whateverParamName (DataParameter.Varchar("@whateverParamName", "whateverParamValue"))

Any guidance would be much appreciated.

sdanyliv commented 5 years ago

@journger, looks like you have to pass @ sign. Everything depends on data provider. Many samples of code usage are located in our tests. So it is better to clone linq2db repo and analyse linq2db.sln.

Also T4 generator may generate procedure stubs automatically from real database.

MaceWindu commented 5 years ago

Yep, we have inconsistency here. For ExecuteProc you need to specify parameter name with provider-specific parameter marker, e.g. @, but when you use parameter in query, linq2db adds marker for you. We definitely have area for improvement here.