本文介绍了如何将valyues从存储过程重新分配到类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii,



我有一个名为tblDrivingRegistartion的表,我创建了一个类DrivingIDgistration,它具有相同列的属性..



我正在做以下事情



Hii ,

I have a table named tblDrivingRegistartion and i have created a class DrivingRegistration which has properties of same columns ..

I am doing followinf things

public static DrivingRegistration GetDrivingRegistrationDetailsByEmployeeId(int employeeId)
        {
            DataClasses1DataContext _db = new DataClasses1DataContext();
            ISingleResult<usp_GetDrivingRegistrationDetailsByEmployeeIdResult> result = _db.usp_GetDrivingRegistrationDetailsByEmployeeId(employeeId);

        }





但是没有得到我如何从rsult和returen对象的类注册属性驱动注册类



but not get how i assgin value to class properties from rsult and returen object of drivingregistration class

推荐答案

public static DrivingRegistration GetDrivingRegistrationDetailsByEmployeeId(int employeeId)
       {
           DataClasses1DataContext _db = new DataClasses1DataContext();
           ISingleResult<usp_GetDrivingRegistrationDetailsByEmployeeIdResult> result = _db.usp_GetDrivingRegistrationDetailsByEmployeeId(employeeId);

           // you can map the <usp_GetDrivingRegistrationDetailsByEmployeeIdResult> properties to the
           //<DrivingRegistration> properties as

           DrivingRegistration objdriving = new DrivingRegistration();
           if (result != null)
           {
               var temp = result.FirstOrDefault();
               if (temp != null) { }
               objdriving.PropertyName = temp.PropertyName; // map your properties
               objdriving.ColumnName1 = temp.ColumnName1; // map your properties
           }


           return objdriving;

       }


[Function(Name = "usp", IsComposable = false)]
public ISingleResult<DrivingRegistration > GetDALDrivingRegistrationDetailsByEmployeeId()
{
    IExecuteResult objResult =
      this.ExecuteMethodCall(this,(MethodInfo)(MethodInfo.GetCurrentMethod()));

    ISingleResult<DrivingRegistration> objresults =
        (ISingleResult<DrivingRegistration>) objResult.ReturnValue;
    return objresults;
}



从DbContext调用此方法

参考此文



[]



还有一个参考



映射存储CP链接的实体类部分的过程

[]


这篇关于如何将valyues从存储过程重新分配到类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 05:33