We are using x-tensive ORM, and i want to implement below query in xtensive.

sql query is following. show table like'ItemMaster'

Means hot to manipulate and access the database table at dynamic time in xtensive orm.

for example , can we create table ,check table exist in DB at dynamic time in xtensive.

asked Oct 10 '16 at 16:42

JMSC's gravatar image

JMSC
5111


One Answer:

Maybe this what you want

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

using (var cmd = accessor.CreateCommand())
{
    cmd.CommandText = "do something";
    cmd.CommandType = CommandType.Text;

    /*  
        Add some parameters if needed

        var p = cmd.CreateParameter();
        p.Value = value;
        p.ParameterName = name;
        cmd.Parameters.Add(p);
    */

    // Now get results
    var val = cmd.ExecuteScalar(); // if query return scalar value
    using (var reader = cmd.ExecuteReader()) // if query return table value, get rows will be while(reader.Read())
    cmd.ExecuteNonQuery(); // if we don't bother about return value
}

answered Oct 11 '16 at 01:24

Anton%20Guschin's gravatar image

Anton Guschin
73233035

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

Subscription:

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

Tags:

×3
×3
×1
×1

Asked: Oct 10 '16 at 16:42

Seen: 1,092 times

Last updated: Oct 11 '16 at 01:24

powered by OSQA