質問

I've a method like below, given a table name and where condition (column and value) the idea is obtain the primary key value for this condition

    public static int getid(string table, string wherecolumn, string wherevalue) {
        SubSonic.TableSchema.Table t = new TableSchema.Table(table);
        SubSonic.Select s1 = new SubSonic.Select(t.PrimaryKey);
        s1.From(t);
        s1.Where(wherecolumn).IsEqualTo(wherevalue);
        return s1.ExecuteScalar<int>();
    }

My Table "t" is created without errors, but t.PrimaryKey and other members are always null, how can I resolve this using subsonic 2.x? Thanks!

役に立ちましたか?

解決

Try this:

var t = DataService.GetSchema(table, providername);

Where the provider name is in your subsonic web config section.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top