2016-02-03 3 views
-5

эта ошибка появляется enter image description hereне может преобразовать из 'в'?

** У меня есть эта ошибка не может конвертировать из «в» **

using SCB_Common.ExtensionMethods; 
using System.Data.SqlClient; 

namespace SCB_Common.DataBase 
{ 
    public class BusinessCommon 
    { 
     public static void SetCommonCloumns(SqlDataReader DR, EntityCommon entity) 
     { 
      entity.CreatedAt = DR.GetDateTime("CreatedAt"); 
      entity.CreatedBy = DR.GetDecimal("CreatedBy"); 

      entity.LastModifyAt = DR.GetDateTime("LastModifyAt"); 
      entity.LastModifyBy = DR.GetDecimal("LastModifyBy"); 
      entity.ModifyBy = DR.GetDecimal("ModifyBy"); 

      entity.PostStateAt = DR.GetDateTime("PostStateAt"); 
      entity.PostStateBy = DR.GetDecimal("PostStateBy"); 

      entity.RecordState = DR.GetInt32("RecordState"); 
      entity.I_D = DR.GetDecimal("I_D"); 
     } 
    } 
} 

** это метод получения записи, когда я называю SCB_Common.DataBase.BusinessCommon.SetCommonCloumns (DR, сущность); **

public Entity.SBH_D_Guardianship_Type_Entity GetRecord(Entity.SBH_D_Guardianship_Type_Entity ent, out bool IsDeleted) 
    { 
     IsDeleted = true; 
     Entity.SBH_D_Guardianship_Type_Entity entity = null; 

     SqlDataReader DR = Action.GetDataList(ent, 1, 1, ""); 
     while (DR.Read()) 
     { 
      IsDeleted = false; 

      entity = new Entity.SBH_D_Guardianship_Type_Entity(); 
      entity.ID = DR.GetDecimal("ID"); 
      entity.Aname = DR.GetString("Aname"); 
      entity.Ename = DR.GetString("Ename"); 

      SCB_Common.DataBase.BusinessCommon.SetCommonCloumns(DR, entity); 
     } 
     DR.Close(); 

     return entity; 
    } 

это класс сущности

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 

namespace SCB_HR_Business.Entity 
{ 
    public class SBH_D_Guardianship_Type_Entity 
    { 
     public decimal ID_Co 
     { get; set; } 

     public decimal ID 
     { get; set; } 
     public string Aname 
     { get; set; } 
     public string Ename 
     { get; set; } 
     public decimal I_D 
     { get; set; } 

     public object LastModifyBy { get; set; } 

     public object CreatedBy { get; set; } 
    } 
} 
+0

Как 'SBH_D_Guardianship_Type_Entity' относится к' Entity'? Очевидно, вы передаете экземпляр первого, где последний требуется на «SetCommonCloumns». – HimBromBeere

+0

i edit the questiont –

+1

'SBH_D_Guardianship_Type_Entity', похоже, не принадлежит к' EntityCommon', что и является вторым параметром 'SetCommonCloumns'. –

ответ

1

Тип SBH_D_Guardianship_Type_Entity не EntityCommon, я имею в виду, это не inheriths от EntityCommon. Метод SetCommonCloumns за исключением второго аргумента EntityCommon. Попробуйте это:

public class SBH_D_Guardianship_Type_Entity : EntityCommon 
{ 
    public decimal ID_Co { get; set; } 

    public decimal ID { get; set; } 
    public string Aname { get; set; } 
    public string Ename { get; set; } 
    public decimal I_D { get; set; } 
} 

И помните, чтобы удалить свойства, которые вы определили на EntityCommon.

+0

спасибо, что это работа –

Смежные вопросы