put if clause in Editor
put if clause in Editor
suwarjono@daunbiru.com
Posts: 10Questions: 2Answers: 0
in Editor
Hi Support
i need sime if cluase in where editor. how could be done.
using (var db = new Database(settings.DbType, settings.DbConnection))
{
var response = new Editor(Db, "staff")
.Model<StaffModel>()
.Field(new Field("start_date")
.Validator(Validation.DateFormat(
Format.DATE_ISO_8601,
new ValidationOpts { Message = "Please enter a date in the format yyyy-mm-dd" }
))
.GetFormatter(Format.DateSqlToFormat(Format.DATE_ISO_8601))
.SetFormatter(Format.DateFormatToSql(Format.DATE_ISO_8601))
)
// need some if clause where in here
// if(x > 0) .where ("db","id","=")
//
.Process(request)
.Data();
return Json(response);
}
please give suggest
This discussion has been closed.
Answers
Hi,
The Editor .NET manual describes how a where condition can be used on the data set.
Regards,
Allan
Hi allan,
Yess you're right.
But i want ask some thing like this
// need some if clause where in here
// if(x > 0) .where ("db","id","=")
//
Like my comment on my question above.
Thanks
Two options:
1) Simply break the chain - you don't need to have the Editor configuration in one bit chain. You could easily do:
2). Use a lambda function for the
Where
method and add the condition in there.Allan
hi allan,
i've trying like you said, but its failed. what doyou think, where is my probblem?
please give suggest
thanks
In what way did it fail? I presume it gave an error message - what was that message? What is
x
- I presume that is defined higher up in the function?Allan
Hi Allan,
here my console.log error feedback
i dont understand which code was wrong..
please give advice.
//br
thanks
I'm afraid I don't from the information available either! Can you give me a link to the page so I can debug it please.
What is the JSON reply from the server just before this error happens?
Allan