Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Convert or map/add Entity Framework Stored Procedure Result Set records to user defined class...

$
0
0

Hi there,

I have stored procedure which I have imported in EF and its returning n number of records and its return type is  ObjectResult<spGetProductData_Result1> this result set I am storing in IEnumerable < Object > splist = entity.spGetData(startDate, end, "AAA").ToList();

Now what I want is that this splist object records to store in user defined class for further processing but when trying to do that its generating error saying "Unable to cast the...."

List < Special > spl = new List < Special > ();
DBEntities entity = new DBEntities();
DateTime ? startDate = Convert.ToDateTime("2017-01-01");
DateTime ? end = Convert.ToDateTime("2017-04-18");
IEnumerable < Object > splist = entity.spGetData(startDate, end, "AAA").ToList();

public class Special {
  public int ? NO {
    get;
    set;
  }
  public string[] SNo {
    get;
    set;
  }
  public string[] Div {
    get;
    set;
  }
  public string[] ITEMO {
    get;
    set;
  }
  public DateTime ? DDT {
    get;
    set;
  }

}

 I converted it to IEnumerable List but I want to iterate through each record and make my own custom selected objects list and pull the data inside Special class object.


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>