I have posted a sample project, please take a look at that.
DDL SQL for the sample
CREATE TABLE customers
(
cus_pk serial NOT NULL,
cus_name character varying NOT NULL DEFAULT ''::character varying,
CONSTRAINT customers_pkey PRIMARY KEY (cus_pk)
)
as per above DDL i have a text field that is defined as NOT NULL default ''. I have been trying to get a working solution to save teh data back to the database.
I have implemented metadata approach as follows
Code: Select all
Public Class CustomerMetaData
<Editable(False)>
<Display(Name:="ID", description:="Unique Identifier")>
Property CusPk() As Integer
<Display(Name:="Customer Name (MetaData)", description:="Full name of customer")>
<DisplayFormat(ConvertEmptyStringToNull:=False)>
Property CusName() As String = ""
End Class
<MetadataType(GetType(CustomerMetaData))>
Partial Public Class Customer
End Class
I would like the option of using the attributes property of the entityproperty, this is what i am trying to make work.
to reproduce the problem.
make sure metadata code is commented out
run the sample
navigate to host:port/customers/create
click create without entering anything in the customer name textbox
an error is thrown with validation error of customer name is required. the problem only happens with a blank customer name. if you enter some text it will create fine.
What do i need to to do to achieve the same functionality as the metadata approach but just using the attributes collection within the CusName entitproperty.
Why do i want to do this, well partly because it is bugging me now, and also i am just starting out, not sure if i would prefer the approach of using the designer rather than maintaining classes myself. not sure, but i am pretty sure it would teach me something to understand how to get it working properly
thanks