TestCondition의 값에 따라 where절 조건문 동적 생성.




SELECT ...

FROM ...

WHERE 1=1

<isNotEmpty property="TestCondition" prepend="AND">

<isEqual property="TestCondition" compareValue="A">

--TestCondition의 값이 A일 때 처리

</isEqual>

<isEqual property="TestCondition" compareValue="B">

--TestCondition의 값이 B일 때 처리

</isEqual>

</isNotEmpty>

반응형

References : http://api.jquery.com/off/http://api.jquery.com/on/





1. 이벤트 등록


$(document).on('click', '#btn_search', searchEvent);


=>$(document)에 존재하는 #btn_search요소를 click했을때 searchEvent를 실행한다.




2. 이벤트 제거


$(document).off('click', '#btn_search');


=> $(document)에 존재하는 #btn_search'요소의 click이벤트를 제거한다.


반응형


Sources 


List<T> listT = new List<T> { };


listT.Sort(delegate (T x, T y) {

    return x.ORDER.CompareTo(y.ORDER);

});



반응형

References


How can I sort generic list DESC and ASC?



Sources


1. Use Linq


var ascendingOrder = li.OrderBy(i => i);

var descendingOrder = li.OrderByDescending(i => i);



2. Not use Linq


li.Sort((a, b) => a.CompareTo(b)); // ascending sort

li.Sort((a, b) => -1* a.CompareTo(b)); // descending sort



3. Make to list.


li = li.OrderBy(i => i).ToList();

반응형


References


How to find the Mode in Array C#? 




Sources


int mode = x.GroupBy(v => v).OrderByDescending(g => g.Count()).First().Key;

반응형

References


some 메서드(Array)(JavaScript)




Source


1. 배열내 모든 요소가 짝수인지 검사하기.


// The callback function.

function CheckIfEven(value, index, ar) {

    if (value % 2 == 0)

        return true;

}


var numbers = [1, 15, 4, 10, 11, 22];


var evens = numbers.some(CheckIfEven);

document.write(evens);


// Output:

// true



2. 기준값을 벗어나는 값이 있는지 검사하기


// Create a function that returns true if the value is 

// outside the range.

var isOutsideRange = function (value) {

    return value < this.minimum || value > this.maximum;

}


// Create an array of numbers.

var numbers = [6, 12, 16, 22, -12];


// The range object is to be the 'this' object.

var range = { minimum: 10, maximum: 20 };


document.write(numbers.some(isOutsideRange, range));


// Output: true

반응형


References 


[Javascript] 숫자 배열의 합을 찾는 방법



Sources


var sum = [1, 2, 3].reduce((a, b) => a + b, 0);

반응형

References 


Function.prototype.apply()




Source


/* min/max number in an array */

var numbers = [5, 6, 2, 3, 7];


/* using Math.min/Math.max apply */

var max = Math.max.apply(null, numbers); /* This about equal to Math.max(numbers[0], ...)

                                            or Math.max(5, 6, ...) */

var min = Math.min.apply(null, numbers);


/* vs. simple loop based algorithm */

max = -Infinity, min = +Infinity;


for (var i = 0; i < numbers.length; i++) {

  if (numbers[i] > max) {

    max = numbers[i];

  }

  if (numbers[i] < min) {

    min = numbers[i];

  }

}



반응형


References


javascript-배열을-스택처럼-다루기




Functions


var arr = [1, 2, 3];


//배열의 첫번째 원소 제거. (첫번째 원소 값을 리턴)

var head = arr.shift();          


//배열의 맨 앞에 1 추가.

arr.unshift(1);


//배열의 맨 뒤에 2 추가.

arr.push(2);


//배열의 마지막 원소 제거. (마지막 원소 값을 리턴)

vat tail = arr.pop();

반응형


Source


var s = 'abcABC';


var temp = s.split('');

s = temp.sort().reverse().join('');




Descriptions


.split()

string을 array로 변경


.sort()

배열을 정렬


.reverse()

정렬된 배열의 순서를 뒤집기


.join()

array타입을 string으로 변경

반응형

+ Recent posts