NEST 增删改查
/// <summary>
/// HEAD /employee/employee/1
/// </summary>
public void DocumentExists()
{
var response = client.DocumentExists<employee>("1一狮");
Console.WriteLine(JsonConvert.SerializeObject(response));
} /// <summary>
/// PUT /employee/employee/1/_create
/// </summary>
public void CreateDoc()
{
var e = new employee()
{
about = "这是about",
age = 26,
first_name = "陈",
interests = new List<string> { "篮球" },
last_name = "小明 小红",
dto = new employeedto { Id = Guid.NewGuid() }
};
var response = client.Create<employee>(e, x => x.Id(e.last_name));
Console.WriteLine(JsonConvert.SerializeObject(response));
} /// <summary>
/// PUT /employee/employee1?op_type=create
/// </summary>
public void IndexDocOptypeCreate()
{
var e = new employee()
{
about = "这是about",
age = 26,
first_name = "陈",
interests = new List<string> { "篮球" },
last_name = "小明 小红",
dto = new employeedto { Id = Guid.NewGuid() }
};
var response = client.Index<employee>(e, x => x.Id(e.last_name).OpType(OpType.Create));
Console.WriteLine(JsonConvert.SerializeObject(response));
} /// <summary>
/// DELETE /employee/employee/2
/// </summary>
public void Delete()
{
var response = client.Delete<employee>("一狮2");
Console.WriteLine(JsonConvert.SerializeObject(response));
} /// <summary>
/// 乐观并发控制
/// PUT /employee/employee/1?version=5
/// </summary>
public void IndexDocVersion()
{
var e = new employee()
{
about = "这是about",
age = 26,
first_name = "陈",
interests = new List<string> { "篮球" },
last_name = "一狮",
dto = new employeedto { Id = Guid.NewGuid() }
};
var response = client.Index<employee>(e, x => x.Id(e.last_name).Version(1));
Console.WriteLine(JsonConvert.SerializeObject(response));
} /// <summary>
/// 乐观并发控制external
/// PUT /employee/employee/1?version=5&version_type=external
/// </summary>
public void IndexDocVersionExternal()
{
var e = new employee()
{
about = "这是about",
age = 26,
first_name = "陈",
interests = new List<string> { "篮球" },
last_name = "一狮",
dto = new employeedto { Id = Guid.NewGuid() }
};
var response = client.Index<employee>(e, x => x.Id(e.last_name).Version(5).VersionType(VersionType.External));
Console.WriteLine(JsonConvert.SerializeObject(response));
} /// <summary>
/// 更新
/// POST /employee/employee/1/_update
/// </summary>
public void Update()
{
var response = client.Update<employee>("一狮", x => x.Doc(new employee() { height = 180 }));
Console.WriteLine(JsonConvert.SerializeObject(response));
} /// <summary>
/// 更新
/// POST /employee/employee/1/_update?retry_on_conflict=3
/// </summary>
public void UpdateRetryOnConflict()
{
var response = client.Update<employee>("一狮", x => x.Doc(new employee() { height = 180 }).RetryOnConflict(3));
Console.WriteLine(JsonConvert.SerializeObject(response));
} /// <summary>
/// 获取多个doc
/// POST /_mget
/// </summary>
public void Mget()
{
var response = client.MultiGet(x => x.Type("employee").Get<employee>(g => g.Id("一狮")).Type("employee").Get<employee>(gg => gg.Id("小明 小红")));
Console.WriteLine(JsonConvert.SerializeObject(response));
} /// <summary>
/// 获取多个doc
/// POST /employee/employee/_mget
/// </summary>
public void Mget2()
{
var response = client.MultiGet(x => x.Index("employee").Type("employee").Get<employee>(g => g.Id("一狮")).Get<employee>(gg => gg.Id("小明 小红")));
Console.WriteLine(JsonConvert.SerializeObject(response));
} /// <summary>
/// 批量操作
/// POST /_bulk
/// </summary>
public void Bulk()
{
var response = client.Bulk(x => x.Create<employee>(e => e.Document(new employee() { last_name = "Bulk1" })).Create<employee>(e => e.Document(new employee() { last_name = "Bulk2" })));
Console.WriteLine(JsonConvert.SerializeObject(response));
}
NEST 增删改查的更多相关文章
- Dapper逆天入门~强类型,动态类型,多映射,多返回值,增删改查+存储过程+事物案例演示
Dapper的牛逼就不扯蛋了,答应群友做个入门Demo的,现有园友需要,那么公开分享一下: 完整Demo:http://pan.baidu.com/s/1i3TcEzj 注 意 事 项:http:// ...
- ASP.NET从零开始学习EF的增删改查
ASP.NET从零开始学习EF的增删改查 最近辞职了,但是离真正的离职还有一段时间,趁着这段空档期,总想着写些东西,想来想去,也不是很明确到底想写个啥,但是闲着也是够 ...
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(9)-MVC与EasyUI结合增删改查
系列目录 文章于2016-12-17日重写 在第八讲中,我们已经做到了怎么样分页.这一讲主要讲增删改查.第六讲的代码已经给出,里面包含了增删改,大家可以下载下来看下. 这讲主要是,制作漂亮的工具栏,虽 ...
- 通过Java代码实现对数据库的数据进行操作:增删改查
在写代码之前,依然是引用mysql数据库的jar包文件:右键项目-构建路径-设置构建路径-库-添加外部JAR 在数据库中我们已经建立好一个表xs :分别有xuehao xingming xue ...
- Hibernate全套增删改查+分页
1.创建一个web工程 2.导入jar包 3.创建Student表 4.创建实体类 package com.entity; public class Student { private Integer ...
- 使用 Json.Net 对Json文本进行 增删改查
JSON 已经成为当前主流交互格式, 如何在C#中使用 Json.Net 对Json文本进行 增删改查呢?见如下代码 #region Create (从零创建) public static strin ...
- yii2 增删改查
自己总结的yii2 advanced 版本的简单的增删改查,希望对大家有所帮助 1.gii生成的actionCreate()方法中 获取插入语句的id $id = $model->attribu ...
- Batis-iBatis基本操作(增删改查)
Batis-iBatis基本操作(增删改查) 时间 2014-04-10 17:55:20 CSDN博客 原文 http://blog.csdn.net/mazhaojuan/article/de ...
- JS组件系列——又一款MVVM组件:Vue(一:30分钟搞定前端增删改查)
前言:关于Vue框架,好几个月之前就听说过,了解一项新技术之后,总是处于观望状态,一直在犹豫要不要系统学习下.正好最近有点空,就去官网了解了下,看上去还不错的一个组件,就抽空研究了下.最近园子里vue ...
随机推荐
- 集合类 collection接口 LinkedList
LinkedList 是另外一种重要的数据结构形式, 底层是使用了双向链表数据结构, 特点: 查询速度慢,增删快. 继承关系如下: 可以发现,LinkedList同时实现了Quene和Deque接口. ...
- 第06组 Beta冲刺(3/5)
队名:拾光组 组长博客链接 作业博客链接 团队项目情况 燃尽图(组内共享) 组长:宋奕 过去两天完成了哪些任务 继续维护后端代码 学习深入python 研究匿名拨打电话问题.套牌多结果处理问题 Git ...
- Cannot capture jmeter traffic in fiddler
Cannot capture jmeter traffic in fiddler First, change Fiddler's port back to 8888 as it was origina ...
- 升级ruby的版本 https://gems.ruby-china.com/
升级ruby版本,有时候安装ruby的版本过低,需要进行升级,例如安装在centos6.7安装fpm需要ruby版本在1.9以上. 1.主机环境如下: 1 [root@test ~]# cat /et ...
- ubuntu16.04 安装使用meld及问题
本文链接:https://blog.csdn.net/ai_liuliu/article/details/95504095安装meldsudo apt-get install meld启动meld方法 ...
- android RelativeLayout实现左中右布局
RelativeLayout实现左中右布局 <RelativeLayout android:layout_width="match_parent" android:lay ...
- [LeetCode] 496. Next Greater Element I 下一个较大的元素 I
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of n ...
- sonar:默认的扫描规则
https://blog.csdn.net/liumiaocn/article/details/83550309 https://note.youdao.com/ynoteshare1/index.h ...
- web自动化测试笔记(二)
如何使用selenium工具 上章节介绍了搭建web自动化的环境,这个章节介绍如何使用selenium写自动化脚本. 1.selenium selenium是一个用于web应用程序的测试工具.它可以帮 ...
- 查看LINUX进程内存占用情况及启动时间
可以直接使用top命令后,查看%MEM的内容.可以选择按进程查看或者按用户查看,如想查看oracle用户的进程内存使用情况的话可以使用如下的命令: (1) top top命令是Linux下常用的性能分 ...