AutoCRUD Update with Named Connection

I have added the ability to used named connections to my AutoCRUD classes by implementing the IChangeDb interface, but only using the NamedConnection property.

This works fine for GET, POST and DELETE requests, but the PUT request always fails with the message ‘NamedConnection’ is not a property of ‘Channel’.

This is a sample of a POST request, which works fine:

[ProtoContract]
public class CreateChannel : ICreateDb< Channel >, IReturn< CreateChannelResponse >, IChangeDb
{
    [ProtoMember( 1 )]
    public string Name { get; set; }

    [ProtoMember( 2 )]
    public string Type { get; set; }

    [ProtoMember( 3 )]
    public string NamedConnection { get; set; }
}

And the DELETE request, which also works:

[ProtoContract]
public class DeleteChannel : IDeleteDb< Channel >, IReturn< DeleteChannelResponse >, IChangeDb
{
    [ProtoMember( 1, DataFormat = DataFormat.ZigZag )]
    public int Id { get; set; }

    [ProtoMember( 2 )]
    public ulong RowVersion { get; set; }

    [ProtoMember( 3 )]
    public string NamedConnection { get; set; }
}

And this is a sample of a PUT request, which produces the error:

[ProtoContract]
public class UpdateChannel : IUpdateDb< Channel >, IReturn< UpdateChannelResponse >, IChangeDb
{
    [ProtoMember( 1, DataFormat = DataFormat.ZigZag )]
    public int Id { get; set; }

    [ProtoMember( 2 )]
    public string Name { get; set; }

    [ProtoMember( 3 )]
    public string Type { get; set; }

    [ProtoMember( 4 )]
    public ulong RowVersion { get; set; }

    [ProtoMember( 5 )]
    public string NamedConnection { get; set; }
}
public interface IChangeDb
{
    string NamedConnection { get; set; }
}

The exception is thrown at:

ServiceStack.OrmLite.ModelDefinition.ThrowNoFieldException(String fieldName) in C:\\BuildAgent\\work\\27e4cc16641be8c0\\src\\ServiceStack.OrmLite\\ModelDefinition.cs:line 150

Do you have any suggestions as to what I’m doing wrong?

Regards,
Alan

You can ignore properties with:

AutoQuery.IgnoreCrudProperties.Add(nameof(IChangeDb.NamedConnection));

That did the trick, thanks.

It might be worth mentioning this in the documentation because I spent quite some time trying to track this down.

Regards,
Alan

1 Like

FYI I’ve changed the default behavior to silently ignore properties that don’t match the datamodel in the latest v5.9.1 that’s now available on MyGet.

That’s even better, thanks!

1 Like