I am using Entity Framework for my current project. One of my returning me Dynamic Columns according to condition. i dont know how many columns my SP will return to me.....How to Map sunh kinda SP in EF....
The entity framework creates a strongly typed class at design time to hold the data returned from the database. If you do not have a fixed set of columns you will need to use ado,net for access this stored procedure
thanks for reply sir.....you mean to say EF no gonna help in this case...i have to use old SP Senario to complete that task......
Yes,EF or LINQ-TO-SQL is used to deal with a fixed structure of model entity。Compared with this,you'd better use SqlDataAdapter.Fill method by dynamically setting its property of SelectCommand.CommandText and SelectCommand.Parameters。
If you really must use EF you will have convert to a vertical model, but beware that you will a lot of extra work in get the columns and values.
You might also look at dependency injection as you could alter the map at run time to create the necessary strongly typing that is necessary for EF. But DI is can be tricky.
ravi010mitta...
Member
159 Points
122 Posts
Get Dynamic Columns With SP using EF ?
Feb 24, 2012 09:12 AM|LINK
Hello World
I am using Entity Framework for my current project. One of my returning me Dynamic Columns according to condition. i dont know how many columns my SP will return to me.....How to Map sunh kinda SP in EF....
Please let me know ASAP
Ravi Mittal
Code Help Code
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: Get Dynamic Columns With SP using EF ?
Feb 24, 2012 10:11 AM|LINK
The entity framework creates a strongly typed class at design time to hold the data returned from the database. If you do not have a fixed set of columns you will need to use ado,net for access this stored procedure
Space Coast .Net User Group
ravi010mitta...
Member
159 Points
122 Posts
Re: Get Dynamic Columns With SP using EF ?
Feb 24, 2012 10:22 AM|LINK
thanks for reply sir.....you mean to say EF no gonna help in this case...i have to use old SP Senario to complete that task......
Ravi Mittal
Code Help Code
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Get Dynamic Columns With SP using EF ?
Feb 26, 2012 12:16 AM|LINK
Yes,EF or LINQ-TO-SQL is used to deal with a fixed structure of model entity。Compared with this,you'd better use SqlDataAdapter.Fill method by dynamically setting its property of SelectCommand.CommandText and SelectCommand.Parameters。
skcookie
Member
534 Points
138 Posts
Re: Get Dynamic Columns With SP using EF ?
Feb 26, 2012 04:58 AM|LINK
If you really must use EF you will have convert to a vertical model, but beware that you will a lot of extra work in get the columns and values.
You might also look at dependency injection as you could alter the map at run time to create the necessary strongly typing that is necessary for EF. But DI is can be tricky.
Patrick P.
Microsoft Certified Professional
Remember to mark as answer where appropriate!