Tutorial :SubSonic CreatedBy



Question:

I have a CreatedBy column in a table which datatype is a int. SubSonic crashes on this because apperently it uses CreatedBy, CreatedOn, ModifiedBy and ModifiedOn. The By columns need to be strings.

Is there a way to let SubSonic know that it has to ignore these columns?


Solution:1

No, you probably are going to have to rename the column to CreateByUser or something.

You can also change it to a nvarchar(50) and create a column ModifiedBy nvarchar(50) and have it work just fine too.


Solution:2

Yes... this is totally doable. First of all show us the code that makes it crash. I probably know what it is. You are probably trying to do something like this

MyRecord.Save();  

Where as you need to do pass in the id of the person that is creating the record aka.

MyRecord.Save(55);  

SubSonic knows what datatype your columns are so you don't need to tell it what datatype it is. Also if you look there are overloads of the Save method namely Save(int id), Save(string id), and Save(Guid id). So as long as you use an int,string or guid for your CreateBy column you are good to go, you just need to remember to pass in the ID as SubSonic expects it if you use those columns.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »