/// <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 增删改查的更多相关文章

  1. Dapper逆天入门~强类型,动态类型,多映射,多返回值,增删改查+存储过程+事物案例演示

    Dapper的牛逼就不扯蛋了,答应群友做个入门Demo的,现有园友需要,那么公开分享一下: 完整Demo:http://pan.baidu.com/s/1i3TcEzj 注 意 事 项:http:// ...

  2. ASP.NET从零开始学习EF的增删改查

           ASP.NET从零开始学习EF的增删改查           最近辞职了,但是离真正的离职还有一段时间,趁着这段空档期,总想着写些东西,想来想去,也不是很明确到底想写个啥,但是闲着也是够 ...

  3. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(9)-MVC与EasyUI结合增删改查

    系列目录 文章于2016-12-17日重写 在第八讲中,我们已经做到了怎么样分页.这一讲主要讲增删改查.第六讲的代码已经给出,里面包含了增删改,大家可以下载下来看下. 这讲主要是,制作漂亮的工具栏,虽 ...

  4. 通过Java代码实现对数据库的数据进行操作:增删改查

    在写代码之前,依然是引用mysql数据库的jar包文件:右键项目-构建路径-设置构建路径-库-添加外部JAR 在数据库中我们已经建立好一个表xs :分别有xuehao  xingming    xue ...

  5. Hibernate全套增删改查+分页

    1.创建一个web工程 2.导入jar包 3.创建Student表 4.创建实体类 package com.entity; public class Student { private Integer ...

  6. 使用 Json.Net 对Json文本进行 增删改查

    JSON 已经成为当前主流交互格式, 如何在C#中使用 Json.Net 对Json文本进行 增删改查呢?见如下代码 #region Create (从零创建) public static strin ...

  7. yii2 增删改查

    自己总结的yii2 advanced 版本的简单的增删改查,希望对大家有所帮助 1.gii生成的actionCreate()方法中 获取插入语句的id $id = $model->attribu ...

  8. Batis-iBatis基本操作(增删改查)

    Batis-iBatis基本操作(增删改查) 时间 2014-04-10 17:55:20  CSDN博客 原文  http://blog.csdn.net/mazhaojuan/article/de ...

  9. JS组件系列——又一款MVVM组件:Vue(一:30分钟搞定前端增删改查)

    前言:关于Vue框架,好几个月之前就听说过,了解一项新技术之后,总是处于观望状态,一直在犹豫要不要系统学习下.正好最近有点空,就去官网了解了下,看上去还不错的一个组件,就抽空研究了下.最近园子里vue ...

随机推荐

  1. 使用pwn_deploy_chroot部署国赛pwn比赛题目

    目录 使用pwn_deploy_chroot部署国赛pwn比赛题目 一.前言 二.Docker 三.部署镜像 四.pwn_deploy_chroot 五.check && exp 六. ...

  2. POP IM 产品分析报告

    一.   体验环境 产品名称:POP IM 软件版本:v2.4.0 手机系统:一加5T Android 9 体验时间:2019.10.22-2019.10.31 二.   产品简介 1.   产品定位 ...

  3. spring-JDBC模板

    Spring的JDBC的模板 Spring是EE开发的一站式的框架,有EE开发的每层的解决方案. Spring对持久层也提供了解决方案:ORM模块和JDBC的模板. Spring提供了很多的模板用于简 ...

  4. Git提交(PUSH)时记住密码 - 不用每次都输入密码

    开发使用的团队搭建好的GitLab服务器来作为项目共享开发,由于我不是最高权限,没办法把我git生成的SSH-Key放到服务器里面去,所有只好在每次提交的时候配置git config来记录密码不过期来 ...

  5. Python常用模块大全

    Python常用模块大全 os模块: os.remove() 删除文件 os.unlink() 删除文件 os.rename() 重命名文件 os.listdir() 列出指定目录下所有文件 os.c ...

  6. Pandas进阶之DataFrame多级索引

    多级索引:在一个轴上有多个(两个以上)的索引,能够以低维度形式来表示高维度的数据.单级索引是Index对象,多级索引是MultiIndex对象. 一.创建多级索引 方法一:隐式创建,即给DataFra ...

  7. BIM数据格式中IFC的标准及格式

    传统工程数据往往零散且片段的储存在各个不同的地方,数据格式也有各种不同的形式互相搭配,最常见的有图形(施工图.大样图.断面图.流程图等).文字(各种说明文件).数字(各种统计.数量或价格数据),这些数 ...

  8. SpringBoot 使用AOP记录接口访问日志

    文章来源:https://macrozheng.github.io/mall-learning/#/technology/aop_log AOP AOP为Aspect Oriented Program ...

  9. [LeetCode] 121. Best Time to Buy and Sell Stock 买卖股票的最佳时间

    Say you have an array for which the ith element is the price of a given stock on day i. If you were ...

  10. Activiti数据库表结构(23张表5.*版本)

    1  Activiti数据库表结构 1.1      数据库表名说明 Activiti工作流总共包含23张数据表,所有的表名默认以“ACT_”开头. 并且表名的第二部分用两个字母表明表的用例,而这个用 ...