I'm trying to execute SQL directly (with DO.NET installed from Nuget);

I do the following

var directSql = Session.Services.Demand<DirectSqlAccessor>();
var command = directSql.CreateCommand();
command.CommandText = "update MyTable set [Field] = 0";

and get the following error:

Error   7   'Xtensive.IoC.IServiceContainer' does not contain a definition
for 'Demand' and no extension method 'Demand' accepting a first argument of type
'Xtensive.IoC.IServiceContainer' could be found (are you missing a using directive 
or an assembly reference?)

asked Feb 13 '13 at 09:36

Charles's gravatar image


One Answer:

Hello Charles,

Demand() is an extension method, you need to import Xtensive.Core namespace to use it.

Alternatively you could just call Get() method:

var directSql = Session.Services.Get<DirectSqlAccessor>();

Difference between Demand and Get is in handling of unknown services: Get returns null reference, Demand throws exception.

Since DirectSqlAccessor is a standard service it is always available.

answered Feb 13 '13 at 10:26

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview


Once you sign in you will be able to subscribe for any updates here



Asked: Feb 13 '13 at 09:36

Seen: 23,555 times

Last updated: Feb 13 '13 at 10:26

powered by OSQA