GVKun编程网logo

Dapper.SimpleCRUD插入/更新/获取失败并显示消息``实体必须至少具有一个[Key]属性''。

17

本文将带您了解关于Dapper.SimpleCRUD插入/更新/获取失败并显示消息``实体必须至少具有一个[Key]属性''。的新内容,另外,我们还将为您提供关于Averysimpleecharts(

本文将带您了解关于Dapper.SimpleCRUD插入/更新/获取失败并显示消息``实体必须至少具有一个[Key]属性''。的新内容,另外,我们还将为您提供关于A very simple echarts(v3.0) wrapper for react.、Android 之 SimpleAdapter 简单实例和 SimpleAdapter 参数说明、ansible - 发送电子邮件任务失败并显示错误、ansible 中的输出调试失败并显示错误的实用信息。

本文目录一览:

Dapper.SimpleCRUD插入/更新/获取失败并显示消息``实体必须至少具有一个[Key]属性''。

Dapper.SimpleCRUD插入/更新/获取失败并显示消息``实体必须至少具有一个[Key]属性''。

我在达珀(Dapper)刚出生。尝试将CRUD操作与Dapper和Dapper.SimpleCRUD lib合并。这是示例代码…
我的数据模型看起来像

Class Product{  public string prodId {get;set;}  public string prodName {get;set;}  public string Location {get;set;}}

Dapper实施-插入

public void Insert(Product item){    using(var con = GetConnection())    {      con.Insert(item);    }}

由于Db中的ProdId是“身份”列,因此它失败。它如何表明ProdId是DB中的标识列?

Dapper实施-获取

public IEnumerable<Product> GetAll(){        IEnumerable<Product> item = null;        using (var con = GetConnection())        {            item = con.GetList<Product>();        }        return item;}

它给出了一个例外:

“实体必须至少具有一个[Key]属性”!

答案1

小编典典

之所以发生这种情况,是因为您使用的是Dapper扩展程序,该程序已实现了InsertCRUD扩展方法。理想情况下,可以使用简单的方法来实现

con.Execute
在Dapper中,但是由于您要传递一个对象并通过扩展名自动创建一个插入查询,因此需要帮助它理解它,它是给定产品实体的主键,因此进行以下修改将有所帮助:

[Key]public string prodId {get;set;}

其中Key属性应在中Dapper Extension或中实现Component Model

或者,您可以重命名prodIdId,这将自动使其成为密钥。还要检查以下链接,在这里您可以为实体创建一个单独的映射器,从而定义密钥,无论您使用哪种情况

A very simple echarts(v3.0) wrapper for react.

A very simple echarts(v3.0) wrapper for react.

echart-for-react

A very simple echarts(v3.0) wrapper for react. https://github.com/hustcc/echarts-for-react

install

npm install echart-for-react

How to run the demo:

git clone git@github.com:hustcc/echarts-for-react.git

npm install

npm start

then open http://127.0.0.1:8080/ in your browser. or see http://hustcc.github.io/echarts-for-react/

usage

Simple demo code: more can see: http://hustcc.github.io/echarts-for-react/

import React from 'react';
import ReactEcharts from '../src/echarts-for-react';

<ReactEcharts
    option={this.getotion()} 
    height={300} 
    onEvents={onEvents} />

component props

  • option

the echart option config,can see http://echarts.baidu.com/option.html#title.

  • height

the height of echart. number,with px as it's unit.

  • onChartReady

when chart is ready,will callback the function with the echart object as it's paramter.

  • onEvents

binding the echarts event,will callback the function with the echart event parameter,and the echart object. e.g:

let onEvents = {
    'click': this.onChartClick,'legendselectchanged': this.onChartLegendselectchanged
}
...
<ReactEcharts
    option={this.getotion()} 
    height={300} 
    onEvents={onEvents} />

for more event name,see: http://echarts.baidu.com/api.html#events

Todo

  1. theme props

  2. echart API

LICENSE

MIT

Android 之 SimpleAdapter 简单实例和 SimpleAdapter 参数说明

Android 之 SimpleAdapter 简单实例和 SimpleAdapter 参数说明

SimpleAdapter 的参数说明

 第一个参数 表示访问整个 android 应用程序接口,基本上所有的组件都需要
 第二个参数表示生成一个 Map (String ,Object) 列表选项
 第三个参数表示界面布局的 id  表示该文件作为列表项的组件
 第四个参数表示该 Map 对象的哪些 key 对应 value 来生成列表项
 第五个参数表示来填充的组件 Map 对象 key 对应的资源一依次填充组件 顺序有对应关系
 注意的是 map 对象可以 key 可以找不到 但组件的必须要有资源填充  因为 找不到 key 也会返回 null 其实就相当于给了一个 null 资源
 下面的程序中如果 new String [] { "name", "head", "desc","name"} new int [] {R.id.name,R.id.head,R.id.desc,R.id.head}
这个 head 的组件会被 name 资源覆盖

ansible - 发送电子邮件任务失败并显示错误

ansible - 发送电子邮件任务失败并显示错误

如何解决ansible - 发送电子邮件任务失败并显示错误?

我的 ansible 版本是 2.4

我的目的是发送一封电子邮件,其中包含所有正常运行时间超过 100 天的服务器。仅当清单中的所有服务器均可访问时,以下脚本才能正常工作。

如果清单中的任何服务器不可访问,发送邮件任务将失败并显示以下错误:

任务[发送邮件]


致命:[本地主机]:失败! => {"msg": "该任务包含一个带有未定义变量的选项。错误是:''dict object'' 没有属性 ''stdout''\n\n错误似乎在 ''/ansible/uptime.yml'' : 第 26 行,第 10 列,但可能\n在文件中的其他位置,具体取决于确切的语法问题。\n\n有问题的行似乎是:\n\n 任务:\n - 名称:发送邮件 \n ^ 此处\ n\neexception type: \neexception: ''dict object'' 没有属性 ''stdout''"}

tasks:

  - name: check uptime
    ignore_errors: yes
    shell: uptime |awk ''{print $3}''
    register: up_time

  - name: send mail
    hosts: localhost
    gather_facts: no
    become: no

    tasks:
       - name: send mail
         mail:
           host: relayserver
           port: 25
           from: user@company.com
           to: manager@company.com
           subject: uptime
           body: |-
             {% for server,servervars in hostvars.items() %}
             {% if servervars.up_time.stdout |int >= 100 %}
                {{ server }} - {{"has"}} {{ servervars.up_time.stdout }}
             {% endif %}
             {% endfor %}
         delegate_to: localhost
         run_once: true

我需要邮件任务来忽略无法访问的服务器,并只为可访问的服务器发送邮件。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

ansible 中的输出调试失败并显示错误

ansible 中的输出调试失败并显示错误

如何解决ansible 中的输出调试失败并显示错误?

我正在使用以下剧本

---
- name: ""
  hosts: nexus
  tasks:
    - name: ""
      debug:
        var="{{ vlans | map(attribute=''vlan_id'') | join('','')  }}"

输出为:

ok: [nx01] => {
    "10,20,100,30": "(10,30)"
}

我的输出类型是什么?

我试过了

---
- name: ""
  hosts: nexus
  tasks:
    - name: ""
      debug:
        var="{{ vlans | map(attribute=''vlan_id'') | join('','') | type_debug }} "

但出现错误

ok: [nx02] => {
    "str ": "VARIABLE IS NOT DEFINED!"
}

解决方法

试试这个:

    - name: Create a string with vlans
      debug:
        msg:
          "{{ vlans | map(attribute = ''vlan_id'') | join('','') }}"

    - name: Create a string with vlans | type_debug
      debug:
        msg:
          "{{ vlans | map(attribute = ''vlan_id'') | join('','') | type_debug }}"

输出:

TASK [Create a string with vlans] **************************************
ok: [localhost] => {
    "msg": "10,20,100,30"
}

TASK [Create a string with vlans | type_debug] *************************
ok: [localhost] => {
    "msg": "str"
}

与列表相同的示例:

    - name: Create a list with vlans
      debug:
        msg:
          "{{ vlans | map(attribute = ''vlan_id'') | list | default([]) }}"

    - name: Create a string with vlans | type_debug
      debug:
        msg:
          "{{ vlans | map(attribute = ''vlan_id'') | list | default([]) | type_debug }}"

和输出:

TASK [Create a list with vlans] ***************************************
ok: [localhost] => {
    "msg": [
        10,30
    ]
}

TASK [Create a string with vlans | type_debug] ************************
ok: [localhost] => {
    "msg": "list"
}

如果你需要设置一个变量:

    - name: Set variable
      set_fact:
        mystrvar: "{{ vlans | map(attribute = ''vlan_id'') | join('','') }}"
        mylistvar: "{{ vlans | map(attribute = ''vlan_id'') | list | default([]) }}"

    - name: Debug mystrvar
      debug:
        var: mystrvar

    - name: Debug mystrvar
      debug:
        var: mystrvar | type_debug

    - name: Debug mylistvar
      debug:
        var: mylistvar

    - name: Debug mylistvar
      debug:
        var: mylistvar | type_debug

输出:

TASK [Set variable] *******************************************************
ok: [localhost]

TASK [Debug mystrvar] *****************************************************
ok: [localhost] => {
   "mystrvar": "10,30"
}

TASK [Debug mystrvar] *****************************************************
ok: [localhost] => {
   "mystrvar | type_debug": "str"
}

TASK [Debug mylistvar] ****************************************************
ok: [localhost] => {
    "mylistvar": [
        10,30
    ]
}

TASK [Debug mylistvar] ****************************************************
ok: [localhost] => {
    "mylistvar | type_debug": "list"
}

今天的关于Dapper.SimpleCRUD插入/更新/获取失败并显示消息``实体必须至少具有一个[Key]属性''。的分享已经结束,谢谢您的关注,如果想了解更多关于A very simple echarts(v3.0) wrapper for react.、Android 之 SimpleAdapter 简单实例和 SimpleAdapter 参数说明、ansible - 发送电子邮件任务失败并显示错误、ansible 中的输出调试失败并显示错误的相关知识,请在本站进行查询。

本文标签: