Please rate my web service

Alright I ditched contoso and any other database I was trying and headed straight for AdventureWorks. Was getting the same issue.

I tried key and explicitkey to no avail however what did fix it was having to use a fully qualifying table name as they are shown in AdventureWorks. Why Microsoft did this database that way is a mystery to me :X3:

Edit: I've updated Github. Nowhere near finished but at least getting some joy.

C#:
[Table("Person.Person")]
    public class Person
    {
        [ExplicitKey]
        public int BusinessEntityID { get; set; }
        public string PersonType { get; set; }
        public bool NameStyle { get; set; }
        public string Title { get; set; }
        public string FirstName { get; set; }
        public string MiddleName { get; set; }
        public string LastName { get; set; }
        public string Suffix { get; set; }
        public int EmailPromotion { get; set; }
        public string AdditionalContactInfo { get; set; }
        public string Demographics { get; set; }
    }

adventure-Works.jpg


For other databases it would likely be dbo.Person

Hehe, I can see your issue. It's the singular/plural conundrum I spoke about.

To find the right table name, Dapper Contrib either expects a Table attribute or assumes a pluralized table name.

You don't need to state dbo.Person but because your classname is Person, contrib is expecting a table name of Persons. I'm not sure what the default behaviour is for multiple schemas though ie: schema.Table, or if contrib will detect a correct scheme.pluralizedTable.

Its an old dev argument.

 
Last edited:
Hehe, I can see your issue. It's the singular/plural conundrum I spoke about.



You don't need to state dbo.Person but because your classname is Person, contrib is expecting a table name of Persons. I'm not sure what the default behaviour is for multiple schemas though ie: schema.Table, or if contrib will detect a correct scheme.pluralizedTable.

Yeah otherwise end up with this little gem.

qualifyingtablename.jpg


I will have to experiment around a little with table names but for now that will do I think. Next stop, fight with the generic repo for a while, it's a mess!
 
Yeah otherwise end up with this little gem.

qualifyingtablename.jpg


I will have to experiment around a little with table names but for now that will do I think. Next stop, fight with the generic repo for a while, it's a mess!

Personally, my team uses the singular class, plural Table standard with singular column. Its up to the team/developer but it should be consistent.
 
Personally, my team uses the singular class, plural Table standard with singular column. Its up to the team/developer but it should be consistent.

For years I've used tblPerson, tbl this and tbl that but the more I'm working with EF and now Dapper the more I've started leaning more towards plural table names. Classes though have always been singular I was rapped on the knuckles for that earlier in my career.
 
What's with these naming conventions in AdventureWorks?

adventure-Works.jpg
Schema naming. You can define schema security on the db so restrict a set of users to only that schema. I haven't personally used it but come across ita lot, restrict in large erps.

 
Top
Sign up to the MyBroadband newsletter
X