Click here to Skip to main content
15,439,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Good day to you. I am returning a result as preceding from SQL stored procedure.
Image[^]
Now I am binding the data as follows.
C#
List<EventPhotos> resList = null;
resList = pe.Database.SqlQuery<EventPhotos>(sqlQuery, param).ToList();

Following is my model.
C#
public partial class EventPhotos
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public EventPhotos()
        {

        }        

        public EventInfo EventInformation { get; set; }
        public ImageInfo ImageInformation { get; set; }

    }

    public class EventInfo
    {
        public string EventID { get; set; }

        public string EventName { get; set; }

        public bool IsJoint { get; set; }
    }
    public class ImageInfo
    {
        public string ImageID { get; set; }

        public string EventMediaFolder { get; set; }

        public string Image { get; set; }

        public string DateTime { get; set; }

        public string ImageDescription { get; set; }

        public string Action { get; set; }
    }

But when I run this, nothing gets mapped to my properties EventInformation and ImageInformation. Is there anyway to achieve this. I know this can be done if we use dataAdapter and assign names to the each table retrieved. But I want to use the Entity framework. Any help is appreciated. Thanks in advance.

What I have tried:

I tried to return the properties as list, that was also not working.
Posted
Comments
Maciej Los 10-Jun-16 4:34am    
You have to check what happens in SqlQuery method. Debug the programme to find out the reason.
Sibeesh Passion 10-Jun-16 4:53am    
Hi, Thanks. I have already tried debugging. It just go to the constructor of EventPhotos. And returns back.
John C Rayan 10-Jun-16 5:20am     CRLF
Are you using Code First Approach or DB First Approach. I cant find any link between the tables matching your data models. We need more info with table structure and you SP code too.
Sibeesh Passion 10-Jun-16 5:37am    
Thank you. I am using a code first approach from Database (The last option in Entity Framework), and I created EventPhotos just for mapping the result set.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900