parameterbinding

web api model binding to an interface

流过昼夜 提交于 2019-12-20 10:45:08
问题 I'm trying to bind a controller action to an interface but still maintain the default binding behavior. public class CoolClass : ISomeInterface { public DoSomething {get;set;} // ISomeInterface } public class DosomethingController : ApiController { public HttpResponseMessage Post(ISomeInterface model) { // do something with model which should be an instance of CoolClass } } The consumer of my service knows nothing of CoolClass so having them add "$type" to the Json they are passing would be a

Mysqli parameter binding issue

混江龙づ霸主 提交于 2019-12-14 01:04:31
问题 I need an extra set of eyes on this one. Any help will be greatly appreciated. This is a very simple search query, but for whatever reason I cannot find the bug. Well, I know where the bug is. I just can't get past it. Anyway..... I am taking a search value from a POST variable, setting that variable and then setting a column variable as follows... $term = "'%".$_POST['searchTerm']."%'"; $field = "columnName"; When I echo these they come up perfectly. So if I type "a" in the form I would be

WebApi Multiple actions were found with GetAll() and GetByIds(int[] ids)

 ̄綄美尐妖づ 提交于 2019-12-10 03:32:36
问题 Using the standard route: config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); With these actions: public class ValuesController : ApiController { // GET api/values public string GetAll() { return "all"; } // GET api/values/5 public string GetById(int id) { return "single"; } // GET api/values?ids=1&ids=2 public string GetByIds([FromUri] int[] ids) { return "multiple"; } And make a request to /api/values , I

ASP.Net Web API: Formatter Parameter Binding exception

守給你的承諾、 提交于 2019-12-08 01:38:42
问题 I have a DataContract which my Web API action method accepts as an action parameter. public HttpResponseMessage PostMyObject(MyObjectRequestDc objRequest){ ... } [DataContract] public class MyObjectRequestDc { public MyObjectRequestDc() { References = new List<Uri>(); } [DataMember] public List<Uri> References { get; set; } } One of the properties of the contract is a list of URI objects ('References'). If the client ever submits a request which contains a string that does not resolve to a

How can I determine the parameters that were bound in just the current pipeline step?

懵懂的女人 提交于 2019-12-07 18:50:28
问题 Consider the following script: function g { [CmdletBinding()] param ( [parameter(ValueFromPipelineByPropertyName = $true)]$x, [parameter(ValueFromPipelineByPropertyName = $true)]$y, [parameter(ValueFromPipelineByPropertyName = $true)]$z ) process { $retval = @{psbp=@{};mibp=@{};x=$x;y=$y;z=$z} $PSBoundParameters.Keys | % { $retval.psbp.$_ = $PSBoundParameters.$_ } $PSCmdlet.MyInvocation.BoundParameters.Keys | % { $retval.mibp.$_ = $PSCmdlet.MyInvocation.BoundParameters.$_} return New-Object

How can I determine the parameters that were bound in just the current pipeline step?

让人想犯罪 __ 提交于 2019-12-06 06:00:24
Consider the following script: function g { [CmdletBinding()] param ( [parameter(ValueFromPipelineByPropertyName = $true)]$x, [parameter(ValueFromPipelineByPropertyName = $true)]$y, [parameter(ValueFromPipelineByPropertyName = $true)]$z ) process { $retval = @{psbp=@{};mibp=@{};x=$x;y=$y;z=$z} $PSBoundParameters.Keys | % { $retval.psbp.$_ = $PSBoundParameters.$_ } $PSCmdlet.MyInvocation.BoundParameters.Keys | % { $retval.mibp.$_ = $PSCmdlet.MyInvocation.BoundParameters.$_} return New-Object psobject -Property $retval } } $list = (New-Object psobject -Property @{x=1;z=3}), (New-Object psobject

Laravel: Unknown column $parameter in 'on clause'

倖福魔咒の 提交于 2019-12-04 04:52:19
问题 I have troubles with using a parameter in a DB query and parameter binding in Laravel. I get this error: Error: "Column not found: 1054 Unknown column '3' in 'on clause'" This is the part of a query: ->join('foo AS f1', function($join) use ($bar) { $join->on('f1.foo', '=', 'f2.foo') ->on('f1.bar', '=', $bar); }) If I do this instead, it works: ->on('f1.bar', '=', DB::raw($bar)); What's the solution to this? I would like to use parameter binding for this as well of course. However, when I do:

WebApi2: Custom parameter binding to bind partial parameters

泪湿孤枕 提交于 2019-12-03 07:52:30
问题 I have a webApi2 project and an other project, in which I have my Model classes and a BaseModel that is a base for all Models, as following, public class BaseModel { public string UserId { get; set; } } All the other models are derived from my BaseModel. In webapi I have my CustomerController as following, public class CustomerController : ApiController { [HttpPost] public GetCustomerResponseModel Get(GetCustomerRequestModel requestModel) { var response = new GetCustomerResponseModel(); //I

Are PL/SQL variables in cursors effectively the same as bind parameters?

余生颓废 提交于 2019-11-29 11:45:02
I've heard that using bind variables is (can be) more efficient, because for subsequent calls with a different bind value, the query itself is still the same, so it doesn't need to be parsed anymore. I understand why this is the case for fixed values. In the cursor below, the value is fixed on 1. If I have a different cursor that is the same, except the 1 becomes 2, it is a diffent query. Clear so far. declare cursor C_CURSOR is select * from TESTTABLE pt where pt.ID = 1; But I wondered if this is also the case when using PL/SQL variables inside the cursor. Are they expanded as if it's a fixed

Laravel query builder parameter binding

只愿长相守 提交于 2019-11-29 11:20:05
I'm trying to bind the same value to some parameter in a raw query (Laravel 5.2) //this is a non practical example ,only for clarify the question DB::table('users as u') ->select('id') ->whereRaw('u.id > ? or u.id < ? or u.id = ?',[2,2,2]) ->first(); is there any way to bind the same parameters at once(prevent duplicating values in [2,2,2])? tremby Use named parameters. They're covered in the documentation in the Running Raw SQL Queries section of the Database page , under the subheading Using Named Bindings. Quoting: Instead of using ? to represent your parameter bindings, you may execute a