Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
139 views
in Technique[技术] by (71.8m points)

codefluent - Can not save an entity with the value 0 for a non-nullable numeric property

My model contains an entity Order with a non-nullable property Amount of type decimal:

cf:entity name="Order">
  <cf:property name="Id" />
  <cf:property name="Amount" typeName="decimal" defaultValue="0" nullable="false" />
</cf:entity>

I can not save an instance of this entity with the value 0 for the property Amount, because when calling "Order.Save()" I get the error "Procedure or function 'Order_Save' expects parameter '@Amount', which was not supplied." from SQL-Server.

Everything goes fine if I give the parameter the default value 0 in the stored procedure: ALTER PROCEDURE [dbo].[Order_Save] ( @Amount [decimal] (28, 13) = 0, ...

How can I instruct CodeFluent to generate a stored procedure with the default value 0 for the Amount parameter? Or do you know another solution?

Kind regards

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have to set usePersistenceDefaultValue="false":

<cf:entity name="Order">
  <cf:property name="Id" />
  <cf:property name="Amount" typeName="decimal" nullable="false" usePersistenceDefaultValue="false" />
</cf:entity>

https://www.softfluent.com/documentation/Properties_DefaultValues.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...