optional-parameters

What is best way to search from optional parameter to SQL query in a stored procedure?

断了今生、忘了曾经 提交于 2019-12-08 10:23:45
问题 When it comes to search record with optional parameter in SQL stored procedure, out of these two queries. Both return the same results. Considering performance, which one will you use and why? I have a stored procedure which has multiple search parameters and will be searching in multiple tables, with joins from a huge record set. DECLARE @EventName VARCHAR(100) --SET @EventName = '' --SET @EventName = NULL SET @EventName = 'Coffee in Coffee Bean' -- Query - 1 SELECT * FROM EventDetails WHERE

C# XNA Xbox, in this case optional parameters are not optional

雨燕双飞 提交于 2019-12-08 10:06:26
问题 Apparently optional parameters won't work in C# Xna when used on the Xbox, there non suportedness is stated during compilation. I have a situation like this: func(float? a = null, int? b = null) With large numbers of thease optional parameters that default to the "undefined" value, null. This situation is required. In the simplified example above this can be unwrapped, although this isn't as optional parameters allow: func() func(float? a) func(int? b) func(float? a, int? b) However with

How to pass a method with optional parameters as an argument?

自作多情 提交于 2019-12-07 23:49:35
问题 Say, we have ClassA with method Foo containing an optional parameter. So, we can use it as shown in method DoFoo . public class ClassA { public ClassA() { } public void Foo(bool flag = true) { } public void DoFoo() { Foo(); // == Foo(true); } } Once I needed to pass it to another class ClassB . First I tried to pass it as Action , but the signature surely didn't match. Then I passed it as Action<string> , the signature matched, but the parameter in ClassB was no longer optional. But I did

How to work with Firebase without allowing optional values

谁说我不能喝 提交于 2019-12-07 07:20:28
I'm new to iOS development and I understand that allowing optional values when an object is initialized is not a 'good citizen' technique. That being said, I've read that it is good practice to always have values set, like this: class Item{ var name: String var color: String init(name: String, color: String) { self.name = name self.color = color } } This looks nice and tidy but how can I do something like that working with Firebase? Look what I've got so far: private func loadPosts(){ databaseHandle = ref.child("users/\(self.user.uid)/posts").observe(.value, with:{(snapshot) in var newPosts =

Optional Argument code compiles in .NET 3.5. Why?

北城以北 提交于 2019-12-07 04:27:51
问题 This piece of code compiles OK in VS 2010 in a framework 3.5 project (I triple checked that) public LoggingClient(string uri = "net.msmq://localhost/logging"){...} Why? I see nothing in the C# 4 spec (doc version), section 21.1, that says this should be backwardly compatible. How is it that I get no compilation error? Will this fail silently in some circumstances? 回答1: Project + Properties, Build tab, scroll down, Advanced. You can change the Language Version to "C# 3.0" if you prefer to

How do i set an optional parameter in PHP after the first optional parameter

断了今生、忘了曾经 提交于 2019-12-07 04:21:30
问题 I'm fairly new to php and I am trying to figure how do I set an optional parameter after the first optional parameter? For example I have the following code: function testParam($fruit, $veg='pota',$test='default test'){ echo '<br>$fruit = '.$fruit; echo '<br>$veg = '.$veg; echo '<br>Test = '.$test; } If i make the following calls: echo 'with all parama'; testParam('apple','carrot','some string'); //we get: //with all parama //$fruit = apple //$veg = carrot //Test = some string echo '<hr>

Mixing optional parameters and params when can't simply overload

拥有回忆 提交于 2019-12-06 18:07:55
问题 Similar to this question, I want to mix optional parameters with the params keyword, which of course creates ambiguity. Unfortunately, the answer of creating overloads does not work, as I want to take advantage of caller info attributes, like this: public void Info(string message, [CallerMemberName] string memberName = "", [CallerLineNumber] int lineNumber = 0, params object[] args) { _log.Info(BuildMessage(message, memberName, lineNumber), args); } Creating an overload without the optional

Parameterized query with several optional search terms

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 10:19:00
I have a web application with lots of data, and a search/filter function with several fields, such as name, status, date, and so on. I have been using parameterized queries like this for the regular (non-search) queries: $id = $_POST['itemID']; $db = mysqli_connect($host, $username, $password, $database); $sql_query = "SELECT * FROM tbl_data WHERE ID = ?"; $stmt_query = mysqli_prepare($db, $sql_query); mysqli_stmt_bind_params($stmt_query, "i", $id); mysqli_stmt_execute($stmt_query); //and so on.. How would I protect agains SQL-injection with multiple, optional parameters? There can be up to 10

parameter list (“*”) with lazy “by-name” parameters?

岁酱吖の 提交于 2019-12-06 09:57:42
I can: scala> def foo( f: => String) = println(f) foo: (f: => String)Unit and I can: scala> def foo( f: String*) = f.map(println) foo: (f: String*)Seq[Unit] but I can't: scala> def foo( f: =>String* ) = f.map(println) <console>:1: error: ')' expected but identifier found. def foo( f: =>String* ) = f.map(println) ^ nor scala> def foo( f: (=>String)* ) = f.map(println) <console>:1: error: no by-name parameter type allowed here def foo( f: (=>String)* ) = f.map(println) ^ Is there some other way to do what I want? Why isn't this allowed? Here the => means that the parameter is passed by name.

How to pass a method with optional parameters as an argument?

前提是你 提交于 2019-12-06 08:19:20
Say, we have ClassA with method Foo containing an optional parameter. So, we can use it as shown in method DoFoo . public class ClassA { public ClassA() { } public void Foo(bool flag = true) { } public void DoFoo() { Foo(); // == Foo(true); } } Once I needed to pass it to another class ClassB . First I tried to pass it as Action , but the signature surely didn't match. Then I passed it as Action<string> , the signature matched, but the parameter in ClassB was no longer optional. But I did wanted to have it optional and came to an idea to declare a delegate. So, it worked. public delegate void