I am trying to use a stored procedure through a domain services datasource. I am getting the following error:
the data reader is incompatible with the specified A member of the type does not have a corresponding column in the data reader with the same name
I have followed these steps:
1. Created the entity Data Model
2. Created the function import, selected the stored proc and chose the complex type source in vs2010. (Where it automatically creates the complex type for you)
3. Create the domain service
4. Manually added the complex type result to the domain service class:
public IQueryable<SP1_Result> SP1()
{
return this.ObjectContext.SP1().AsQueryable();
}
5. Added the key to the meta data:
[MetadataTypeAttribute(typeof(SP1_Result.SP1_ResultMetadata))]
public partial class SP1_Result
{
internal sealed class SP1_ResultMetadata
{ [Key]
public int MyId;
}
}
Everything works perfect so far. I can see the datasource from my silverlight grid. Now when I run the app, I get the following error:
The data reader is incompatible with the specified 'MyModel.SP1_Result'. A member of the type, 'MyId1', does not have a corresponding column in the data reader with the same name.
The error is because the stored procedure has a join and the same column name is being used in the two tables (MyId). The error points to MyId1 because it does not exist in any table. What is interesting is that the "add function import" wizard was succesfully
able to create the complex type even though the two tables used the same field name but the domain service was not able to handle this. My question is, does anyone know how to succesfully use a stored procedure that has the same field name twice from a domain
service?
adiel
Member
226 Points
118 Posts
A member of the type does not have a corresponding column in the data reader with the same name
Jul 06, 2011 02:23 PM|LINK
I am trying to use a stored procedure through a domain services datasource. I am getting the following error:
the data reader is incompatible with the specified A member of the type does not have a corresponding column in the data reader with the same name
I have followed these steps:
1. Created the entity Data Model
2. Created the function import, selected the stored proc and chose the complex type source in vs2010. (Where it automatically creates the complex type for you)
3. Create the domain service
4. Manually added the complex type result to the domain service class:
public IQueryable<SP1_Result> SP1()
{
return this.ObjectContext.SP1().AsQueryable();
}
5. Added the key to the meta data:
[MetadataTypeAttribute(typeof(SP1_Result.SP1_ResultMetadata))]
public partial class SP1_Result
{
internal sealed class SP1_ResultMetadata
{
[Key]
public int MyId;
}
}
Everything works perfect so far. I can see the datasource from my silverlight grid. Now when I run the app, I get the following error:
The data reader is incompatible with the specified 'MyModel.SP1_Result'. A member of the type, 'MyId1', does not have a corresponding column in the data reader with the same name.
The error is because the stored procedure has a join and the same column name is being used in the two tables (MyId). The error points to MyId1 because it does not exist in any table. What is interesting is that the "add function import" wizard was succesfully able to create the complex type even though the two tables used the same field name but the domain service was not able to handle this. My question is, does anyone know how to succesfully use a stored procedure that has the same field name twice from a domain service?
Thank You Before Hand,
Adiel
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: A member of the type does not have a corresponding column in the data reader with the same na...
Jul 08, 2011 02:28 AM|LINK
Hello adiel:)
Would you mind showing us your detailled structure of your dataTale and your mapped model in the EF?
Thx