Print Page | Close Window

StoredProcQuery

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1999
Printed Date: 25-Jan-2026 at 3:49am


Topic: StoredProcQuery
Posted By: cbondeson
Subject: StoredProcQuery
Date Posted: 23-Jul-2010 at 11:20am
I am trying to bind a data grid to the result of a stored procedure call. I added the stored procedure to the entity data model. I built my own custom complex entity type.

I edit the CSDL content in XML. I have a tool which generates the XML by iterating through a dataset returned from a call to the proc. It is much faster than doing it by hand.

<ComplexType Name="PatientGetRS_Result">
              <Property Type="Int32" Name="ObjectParentID" Nullable="true" />
              <Property Type="String" Name="LastName" Nullable="true" MaxLength="50" />
              <Property Type="String" Name="FirstName" Nullable="true" MaxLength="50" />
etc
etc
 </ComplexType>



I imported the procedure , inspected the class and associated properties, and all was right with the world. I created a simple xaml with only the data grid and bound it to the ObservableCollection<PatientGetRS_Result> using the complex type.

When I run the app the data grid columns are auto filled but have extra columns not in the <PatientGetRS_Result> class. These include ParentProperty, ParentEntity, VerifierEngine, EntityManager, EntityMetadata, 2 instances of Item, and SerializationContext.

When Silverlight attempts to bind it fails since "Type" occurs twice. I get a "Ambigious Match Found" exception due to the 2 instances of "Item".

Why is DevForce adding these other fields??

I realize that I can set AutoGenerateColumns="False" and then add the columns manually but that really takes away from the elegance of this entity framework.

This is a fix but once again hacky!!!

           var Patient = new PatientGetRS_Result();
            PropertyInfo[] properties = Patient.GetType().GetProperties();
            Array.ForEach(properties, oPropertyInfo =>
            {
                if (oPropertyInfo.Name == "Item")
                    return;

                dataGrid1.Columns.Add(new DataGridTextColumn { Header = oPropertyInfo.Name, Binding = new System.Windows.Data.Binding(oPropertyInfo.Name), IsReadOnly = true });
            });

Once this is done the binding works and the grid updates.



Replies:
Posted By: davidklitzke
Date Posted: 24-Jul-2010 at 6:54am

This would be a bug.  We “hide” properties on the base Entity/EntityWrapper so that automatic field generation produces only the desired application properties and no DF schmutz, but we don’t do this for ComplexTypes. 

 Workaround right now would be to return an Entity type instead of a ComplexType from the function import, or to turn off automatic field generation for the grid.



Posted By: cbondeson
Date Posted: 26-Jul-2010 at 5:40am
We have an app with over  200+ Stored Procs and many returning "complex types" . Will this "bug" be fixed?



Print Page | Close Window