Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I am using petapoco to create custom table in database.
Now I want to change int and datetime property as NULLABLE. so I have set (?) with property datatype.
public int? TotalNumber { get; set; }
I have deleted the tables and running the project. It is creating new table with not Nullable field.
Please suggest what I am missing.
Thanks
It will be good if any one can reply on it.
when I am trying to create table with nullable fields it is creating not nullable fields in tables.
Please suggest what is the approach to make this in petapoco. I have done this many times in MVC entity framwork but this is not working here.
Regards Manish
Hi Manish,
don't think this is possible with PetaPoco when creating the table with the poco. You could try creating the schema by sql. At least I now that with that you could set a field to nullable.
Alter.Table(yourTable).AddColumn("TotalNumber").AsInt32().Nullable();
Maybe this works.
Regards David
Thanks David for reply.
but this will not help in my problem.
I will wait Peta poco new versions if they fix this problem in new versions.
Add this attribute: [NullSetting(NullSetting = NullSettings.Null)]
[NullSetting(NullSetting = NullSettings.Null)] public int? TotalNumber { get; set; }
UPDATE: Does it work with DateTime, I use it in a project.
[NullSetting(NullSetting = NullSettings.Null)] public DateTime? Suporte { get; set; }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Create Nullable field with PetaPoco Model
Hi,
I am using petapoco to create custom table in database.
Now I want to change int and datetime property as NULLABLE. so I have set (?) with property datatype.
public int? TotalNumber { get; set; }
I have deleted the tables and running the project. It is creating new table with not Nullable field.
Please suggest what I am missing.
Thanks
It will be good if any one can reply on it.
when I am trying to create table with nullable fields it is creating not nullable fields in tables.
Please suggest what is the approach to make this in petapoco. I have done this many times in MVC entity framwork but this is not working here.
Regards Manish
Hi Manish,
don't think this is possible with PetaPoco when creating the table with the poco. You could try creating the schema by sql. At least I now that with that you could set a field to nullable.
Maybe this works.
Regards David
Thanks David for reply.
but this will not help in my problem.
I will wait Peta poco new versions if they fix this problem in new versions.
Thanks
Add this attribute: [NullSetting(NullSetting = NullSettings.Null)]
UPDATE: Does it work with DateTime, I use it in a project.
is working on a reply...