views:

52

answers:

2

Hi guys!

Is there somethink like a documentation for subsonic 3? I'm just beginning to use it and have a lot of questions.

First up this error message:

"Can't decide which property to consider the Key - you can create one called 'ID' or mark one with SubSonicPrimaryKey attribute"

The code in question is generated by the context.tt:

    public SqlQuery Delete<T>(Expression<Func<T,bool>> column) where T:new()
    {
        LambdaExpression lamda = column;
        SqlQuery result = new Delete<T>(this.Provider);
        result = result.From<T>();
        result.Constraints=lamda.ParseConstraints().ToList();
        return result;
    }

In my DB the respective table actually has a primary key called ID. And I tried to insert the SubSonicPrimaryKey Attribute:

    uint _ID;
    [SubSonicPrimaryKey]
    public uint ID
    {
        get { return _ID; }
        set
        {...

What's wrong? Someone help me out on this one, please.

Cheers, Dug

+1  A: 

You should post the stack trace of your exception.

This is just a wild guess but I suppose subsonic finds two possible primary keys, the one called ID and one with the SubSonicPrimaryKey attribute and does not check wether they are equal and since the count of the possible keys is not equal to 1 the exception is thrown.

You should try to remove the SubSonicPrimaryKey attribute of your class, since the Property is already called ID.

SchlaWiener
A: 

My guess is that your issue is related to the uint value type. SubSonic has is problems handling unsigned value types. Try using a int property instead for your primary key!

Saintedlama