You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm currently learning how to use NPoco and I have a strange behavior, I can't figure out what am I doing wrong with this. Any help is greatly appreciated.
My database is designed like this :
Agency (Id, AgencyName) User (Id, Name, Agency) where Agency column references Agency.Id
The only noticeable thing here is that the Name property in Agency class is not the same as the database field name (AgencyName).
I am retrieving a user this way:
Useruser= db.Single<User>(@"select [User].Name, [User].Id, [Agency].Id, [Agency].AgencyName FROM [User], [Agency] WHERE [User].Id = @0 AND [Agency].Id = [User].Agency",1);
With this line of code, every members from User and Agency are properly populated with correct values except Name property from Agency class. It is always null.
It seems like I have two options to make the "Name" field properly filled :
Changing the "AgencyName" property to "Name" to make it same as Database column name
Adding "as Name" to [Agency].AgencyName field in the SQL Query
Those 2 ways are correctly filling the property with correct data, but in my understanding, I should not have to make those changes since I'm already adding [Column(Name = "AgencyName")] attribute to the property.
Am I missing something?
Thank you very much for your help.
Regards
The text was updated successfully, but these errors were encountered:
Hi, I'm currently learning how to use NPoco and I have a strange behavior, I can't figure out what am I doing wrong with this. Any help is greatly appreciated.
My database is designed like this :
Agency (Id, AgencyName)
User (Id, Name, Agency) where Agency column references Agency.Id
I made two classes:
Agency class
User class
The only noticeable thing here is that the Name property in Agency class is not the same as the database field name (AgencyName).
I am retrieving a user this way:
With this line of code, every members from User and Agency are properly populated with correct values except Name property from Agency class. It is always null.
It seems like I have two options to make the "Name" field properly filled :
Those 2 ways are correctly filling the property with correct data, but in my understanding, I should not have to make those changes since I'm already adding
[Column(Name = "AgencyName")]
attribute to the property.Am I missing something?
Thank you very much for your help.
Regards
The text was updated successfully, but these errors were encountered: