Frage

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!

War es hilfreich?

Lösung

Try this:

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

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top