2016-03-06 58 views
0

我有一個c#應用程序使用實體框架6和Mysql數據庫。我加入這個存儲過程:使用EF6和Mysql數據庫存儲過程映射

DELIMITER $$ 
CREATE DEFINER=`root`@`localhost` PROCEDURE `ps_reservation`(IN id_compte varchar(128)) 
BEGIN 
    if id_compte is null then 
     SELECT 
      `ajtdev`.`ajt_demande`.`id` AS `id_demande`, 
      `ajtdev`.`ajt_demande`.`date_intervention` AS `date_intervention`, 
      `ajtdev`.`ajt_demande`.`from_time` AS `from_time`, 
      `ajtdev`.`ajt_demande`.`to_time` AS `to_time`, 
      `ajtdev`.`ajt_demande`.`id_begin_place` AS `id_from_place`, 
      `ajtdev`.`ajt_demande`.`id_end_place` AS `id_to_place`, 
      `ajtdev`.`ajt_demande`.`bot` AS `bot`, 
      `ajtdev`.`ajt_client`.`nom` AS `nom_client`, 
      `ajtdev`.`ajt_client`.`prenom` AS `prenom_client`, 
      `ajtdev`.`ajt_coordonne`.`tel` AS `tel_client`, 
      `ajtdev`.`ajt_statut_demande`.`libelle` AS `statut_demande`, 
      `ajtdev`.`ajt_vehicle`.`immarticulation` AS `immarticulation_vehicle`, 
      `ajtdev`.`ajt_vehicle`.`marque` AS `marque_vehicle`, 
      `ajtdev`.`ajt_collaborator`.`id` AS `id_chauffeur`, 
      `ajtdev`.`ajt_collaborator`.`Nom` AS `nom_chauffeur`, 
      `ajtdev`.`ajt_collaborator`.`Prenom` AS `prenom_chauffeur`, 
      `ajtdev`.`ajt_collaborator`.`id_user_fk` AS `id_user` 
     FROM 
      `ajtdev`.`ajt_demande` JOIN `ajtdev`.`ajt_statut_demande` ON (`ajtdev`.`ajt_demande`.`id_statut` = `ajtdev`.`ajt_statut_demande`.`id`) 
      JOIN `ajtdev`.`ajt_client` ON (`ajtdev`.`ajt_demande`.`id_client` = `ajtdev`.`ajt_client`.`id`) 
      JOIN `ajtdev`.`ajt_coordonne` ON (`ajtdev`.`ajt_client`.`id_coordonne` = `ajtdev`.`ajt_coordonne`.`id`) 
      JOIN `ajtdev`.`ajt_ass_veh_col` ON (`ajtdev`.`ajt_demande`.`id_ass_veh_col_fk` = `ajtdev`.`ajt_ass_veh_col`.`id`) 
      JOIN `ajtdev`.`ajt_vehicle` ON (`ajtdev`.`ajt_ass_veh_col`.`veh_id_fk` = `ajtdev`.`ajt_vehicle`.`Id`) 
      JOIN `ajtdev`.`ajt_collaborator` ON (`ajtdev`.`ajt_ass_veh_col`.`col_id_fk` = `ajtdev`.`ajt_collaborator`.`Id`) 
     WHERE 
      ISNULL(`ajtdev`.`ajt_demande`.`deletion_date`) 
      and ISNULL(`ajtdev`.`ajt_collaborator`.`deletion_date`) 
      and ISNULL(`ajtdev`.`ajt_client`.`deletion_date`) 
      and ISNULL(`ajtdev`.`ajt_vehicle`.`deletion_date`); 
    else 
     SELECT 
      `ajtdev`.`ajt_demande`.`id` AS `id_demande`, 
      `ajtdev`.`ajt_demande`.`date_intervention` AS `date_intervention`, 
      `ajtdev`.`ajt_demande`.`from_time` AS `from_time`, 
      `ajtdev`.`ajt_demande`.`to_time` AS `to_time`, 
      `ajtdev`.`ajt_demande`.`id_begin_place` AS `id_from_place`, 
      `ajtdev`.`ajt_demande`.`id_end_place` AS `id_to_place`, 
      `ajtdev`.`ajt_demande`.`bot` AS `bot`, 
      `ajtdev`.`ajt_client`.`nom` AS `nom_client`, 
      `ajtdev`.`ajt_client`.`prenom` AS `prenom_client`, 
      `ajtdev`.`ajt_coordonne`.`tel` AS `tel_client`, 
      `ajtdev`.`ajt_statut_demande`.`libelle` AS `statut_demande`, 
      `ajtdev`.`ajt_vehicle`.`immarticulation` AS `immarticulation_vehicle`, 
      `ajtdev`.`ajt_vehicle`.`marque` AS `marque_vehicle`, 
      `ajtdev`.`ajt_collaborator`.`id` AS `id_chauffeur`, 
      `ajtdev`.`ajt_collaborator`.`Nom` AS `nom_chauffeur`, 
      `ajtdev`.`ajt_collaborator`.`Prenom` AS `prenom_chauffeur`, 
      `ajtdev`.`ajt_collaborator`.`id_user_fk` AS `id_user` 
     FROM 
      `ajtdev`.`ajt_demande` JOIN `ajtdev`.`ajt_statut_demande` ON (`ajtdev`.`ajt_demande`.`id_statut` = `ajtdev`.`ajt_statut_demande`.`id`) 
      JOIN `ajtdev`.`ajt_client` ON (`ajtdev`.`ajt_demande`.`id_client` = `ajtdev`.`ajt_client`.`id`) 
      JOIN `ajtdev`.`ajt_coordonne` ON (`ajtdev`.`ajt_client`.`id_coordonne` = `ajtdev`.`ajt_coordonne`.`id`) 
      JOIN `ajtdev`.`ajt_ass_veh_col` ON (`ajtdev`.`ajt_demande`.`id_ass_veh_col_fk` = `ajtdev`.`ajt_ass_veh_col`.`id`) 
      JOIN `ajtdev`.`ajt_vehicle` ON (`ajtdev`.`ajt_ass_veh_col`.`veh_id_fk` = `ajtdev`.`ajt_vehicle`.`Id`) 
      JOIN `ajtdev`.`ajt_collaborator` ON (`ajtdev`.`ajt_ass_veh_col`.`col_id_fk` = `ajtdev`.`ajt_collaborator`.`Id`) 
     WHERE 
      ISNULL(`ajtdev`.`ajt_demande`.`deletion_date`) 
      and ISNULL(`ajtdev`.`ajt_collaborator`.`deletion_date`) 
      and ISNULL(`ajtdev`.`ajt_client`.`deletion_date`) 
      and ISNULL(`ajtdev`.`ajt_vehicle`.`deletion_date`) 
      and CONVERT(`ajtdev`.`ajt_collaborator`.`id_user_fk` USING UTF8)= id_compte; 
    end if; 

END$$ 
DELIMITER ; 

當我增加了一個新的EF模型,在該方面,我得到這個mappage:

public virtual int ps_reservation(string id_compte) 
{ 
    var id_compteParameter = id_compte != null ? 
     new ObjectParameter("id_compte", id_compte) : 
     new ObjectParameter("id_compte", typeof(string)); 

    return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("ps_reservation", id_compteParameter); 
} 

爲什麼我得到這樣的方法簽名我不明白:

公共虛擬INT ps_reservation(字符串id_compte)

我的意思是,爲什麼返回類型是整數!爲什麼它不是ObjectResult<ps_reservation_Result>

  1. 這個錯誤的原因是什麼?
  2. 我該如何解決?

回答

0

研究

後,我找到了解決辦法here