我不知道我的lambda表达式在做什么,有人可以纠正我吗?

时间:2018-11-05 20:13:56

标签: c# lambda

我正在使用FrameworkEntity并具有两个类:

public class InfoComplementarEmpresaModel
{
    public int idempresa { get; set; }

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

    public string idinformacao { get; set; }
    public string conteudocomplemento { get; set; }
    public string periodocomplemento { get; set; }
}

public class InfoComplementarModel
{
    public int idlayout { get; set; }

    [Key]
    public int idinformacao { get; set; }

    public string codigoinformacao { get; set; }
    public string descricaoinformacao { get; set; }
    public int tipoinformacao { get; set; }
}

我要尝试的lambda连接如下:

public List<string> GetTipoENomeDeInformacaoComplementarEmpresa(string idDaEmpresa)
{
    List<string> listaDeTipos = new List<string>();
    int idDaEmpresaNoFormatocerto = Convert.ToInt32(idDaEmpresa);

    listaDeTipos.Add("Criar novo preenchimento de valores");

    var nomesDeInformacoes = db.InformacoesComplementaresDaEmpresa
        .Where(a => a.idempresa == idDaEmpresaNoFormatocerto)
        .Join(db.InformacoesComplementaresDoLayout,
            infocompempresa => new {infocompempresa.idinformacao},
            infocomplayout => new {infocomplayout.idinformacao},
            (ice, icl) => ice.idinformacao)
        .ToList();

    // some method that will put nomesDeInformacoes in listaDeTipos

    return listaDeTipos;
}

联接指控“无法从用法中推断方法Queryable.Join(IQueryable,IQueryable,Expression>,Expression>,Expression>)的类型参数。尝试显式指定类型参数”

1 个答案:

答案 0 :(得分:0)

我想通了

存在各种问题:

InfoComplementarEmpresaModel中的

idinformacao是字符串而不是int

然后我发现联接中的所有匿名名称必须保持不变,从而导致:

import React, { Component } from "react";
import "./app.scss";
import "react-datepicker/dist/react-datepicker.css";
import DatePicker from "react-datepicker";
import { Button } from "reactstrap";

import Content from "../Content/Content";

import { connect } from "react-redux";
import {
  dateHandleChange,
  dateClickChange } from "../../actions/dateAction";

class App extends Component {
  render() {
    return (
      <div className="mainPanel">
        <div className="datePanel">
          <Button
            outline
            onClick={() => this.clickChange(-1)}
            color="info"
            className="prevDate"
            size="md"
          >
            Previous
          </Button>
          <DatePicker
            dateFormat="YYYY/MM/DD"
            selected={this.props.dateData}
            onChange={date => this.props.dateHandleChange(date)}
            className="dateInput"
          />
          <Button
            outline
            onClick={() => this.props.dateClickChange(1)}
            color="info"
            className="nextDate"
            size="md"
          >
            Next
          </Button>
        </div>
        <Content />
      </div>
    );
  }
}

const mapStateToProps = state => ({
  dateData: state.dateData.startDate
});

export default connect(
  mapStateToProps,
  { dateHandleChange, dateClickChange }
)(App);

这家伙工作了,返回了正在创建的类。