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 ...
随机推荐
- EasyEarth三维可视化解决方案——智慧林业
智慧林业 智能巡管监护 护林员信息查询 护林员管护范围查询 护林员报警.采集数据查看 样点.样线管理 其它功能模块 ●一键考勤打卡 ●面积测量 ●任务公告发布 ●实时电量监控 ●一键报警功能 ●北斗短 ...
- restframework之节流
基本思路(原生Django而言): 在django2.x中,若出现节流(访问频率控制)的需求,我们首先想到的是使用一个字典(dict类型)来存储所有IP地址的访问时间记录,这是针对于匿名用户(IP)而 ...
- Koa Session的使用
Session 简单介绍 session 是另一种记录客户状态的机制,不同的是 Cookie 保存在客户端浏览器中,而 session 保存在服务器上. Session 的工作流程 当浏览器访问服务器 ...
- (转载)基于Linux C的socket抓包程序和Package分析
转载自 https://blog.csdn.net/kleguan/article/details/27538031 1. Linux抓包源程序 在OSI七层模型中,网卡工作在物理层和数据链路层的MA ...
- 第07组 Beta冲刺(5/5)
队名:摇光 队长:杨明哲 组长博客:求戳 作业博客:求再戳 队长:杨明哲 过去两天完成了哪些任务 文字/口头描述:暂时没有. 展示GitHub当日代码/文档签入记录:(组内共用,已询问过助教小姐姐) ...
- ES6继承小实例
ES6继承小实例 一.总结 一句话总结: js中的类和继承可以多用es6里面的,和其它后端语言的使用方法一样 class Animal { constructor(name) { this.name ...
- SQL优化:一些简单的又实用的SQL优化方案【转】
面试过程中,面试官有极高的频率会问道数据库的优化,SQL语句的优化,网上关于SQL优化的教程很多,但是鱼目混杂,显得有些杂乱不堪.近日有空整理了一下,写出来跟大家分享一下,其中有错误和不足的地方,还请 ...
- Learning Context Graph for Person Search
Learning Context Graph for Person Search 2019-06-24 09:14:03 Paper:http://openaccess.thecvf.com/cont ...
- IDEA将指定package(指定文件)打成jar包
写在前面 真的是好记性不如烂笔头 需求 将项目中包名为org的package打成jar包 步骤 1.选择Artifacts>绿色+号>JAR>Empty name自定义, 我这里命名 ...
- unable to lock the administration错误解决
在ubantu系统上,使用 apt-get 命令或者其相对更新的APT 管理工具时,遇到 unable to lock the administration directory (/var/lib/d ...