笔记
1、数组用空格分开拼接字符串
f (product.Keywords != null)
{
pvm.Keywords = string.Join(" ", product.Keywords);
}
2、MongoDB的Map Reduce
var mapFun=function() {
for (var idx = 0; idx < this.OrderDetails.length; idx++) {
var key={productId:this.OrderDetails[idx].ProductId}
var value = {
amount:this.OrderDetails[idx].Amount,
tradeprice: this.OrderDetails[idx].TradePrice
};
emit(key, value);
}
};
var reduceFun=function(key,values){
var totalAmount=0
var totalMoney = 0;
values.forEach(function(value){
totalAmount+=value['amount'];
totalMoney += value['tradeprice']*value['amount'];
});
return {TotalAmount:totalAmount,TotalMoney:totalMoney};
};
db.orders.mapReduce(mapFun,reduceFun,{query:{OrderStatus:1},out:'mapreduce_ProductOrderStatistics'})
2.1MongoDB安装
"D:\MongoDB\bin\mongod.exe" --logpath "D:\MongoDB\logs\mongodb.log" --dbpath "D:\MongoDB\data\" --install --journal
"D:\MongoDB\bin\mongod.exe" --bind_ip 127.0.0.1 --logpath "D:\MongoDB\logs\mongodb.log" --dbpath "D:\MongoDB\data\" --directoryperdb --serviceName MongoDB --service
mongod --logpath D:\MongoDB\log\mongodb.log --logappend --dbpath D:\MongoDB\data --directoryperdb --serviceName MongoDB --install
"D:\MongoDB\bin\mongod.exe" --service -- config="D:\MongoDB\mongo.config"
MongoDBAPI http://api.mongodb.com/js/2.1.2/symbols/Object.html
2.2MongoD
//批量修改
db.getCollection('memberTypes').update({},{$set:{UpGradePoint:1000}},{ multi: true})
3、$in查询包含的值
这个与$all不一样,查询的值在$in给出的范围之内就都可以查出来。例如
db.collection.find({age:{$in:[20,21]}});
可以查询出来 {age:[20,21,22]} 和 {age:[20,22,23]} 以及 {age:[21,22,23]},即只需要有20或者21其中之一的都可以。
4、$exists判断字段是否存在
db.getCollection('users').find({EmployeeProfile:{$exists:true}})
5、null值的处理
null值处理需要注意的是,不仅仅可以查询出来某一字段值为null的记录,还可以查出来不存在某一字段的记录。例如
db.getCollection('users').find({EmployeeProfile:{$exists:true}})
可以查询出来age为null的记录,以及没有age字段的记录。如果我们需要只去查询存在age字段并且age字段的值为null的记录,需要配合exists操作,例如
db.collection.find({age:{"$in":[null],"$exists":true}});
7、$ne不等于操作
可以查询不等于某一字段的数据,例如,查询age不等于20的记录
db.collection.find({age:{$ne:20}});
3、鼠标选中
@model List<string>
@{
Layout = null;
}
<div class="admin">
<div class="layout">
鼠标框选,按住(shift/ctrl)点击或框选,可减去或加上选项。
<div class="line">
@foreach (var item in Model)
{
<div class="xm2 border j_mouse_curs" style="height: 100px;">@item</div>
}
</div>
</div>
</div>
<script src="/html/js/mouse.js"></script>
<style>
/*.admin{ top: 0;}*/
.j_mouse_curs.active {
border-color: #e33;
}
</style>
<script>
new RegionSelect({
region:'.j_mouse_curs',
selectedClass: 'active'
}).select();
</script>
public ActionResult Demo()
{
List<string> list = new List<string>();
for (int i = 0; i < 20; i++)
{
list.Add("abc" + i);
}
return View(list);
}
4、LingerUI
$("#CategeryId").ligerGetComboBoxManager()
$("#CategeryId").ligerGetComboBoxManager().setValue(result.data.CategeryId);
$("#CouponGetType").ligerGetComboBoxManager().setDisabled();
$("#r").ligerSpinner({ disabled: true });
liger.get("checkboxlist1").set('disabled', true);
[BsonRepresentation(BsonType.ObjectId)]
//下拉框
$("#CategeryId").ligerComboBox({
url: '/api/admin/ProductCategory/GetValidCategories',
valueField: 'Key',
textField: 'Value',
autocomplete: true,
ajaxType: 'get',
async: false
});
//checkboxlist
$("#visitstoreckl").ligerCheckBoxList({
url: '/api/admin/user/GetVisitStore',
textField: 'Name',
valueField: "Id",
async: false,
ajaxType: 'get',
rowSize: 5
});
function roleRowSelect(rowdata) {
currentProjectData = rowdata;
smsLogGrid.set({ data: { Rows: currentProjectData.SmsLogs } });
smsLogGrid.reload();
}
浙公网安备 33010602011771号