New Posts New Posts RSS Feed: StoredProcQuery
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

StoredProcQuery

 Post Reply Post Reply
Author
cbondeson View Drop Down
Newbie
Newbie


Joined: 23-Jul-2010
Posts: 2
Post Options Post Options   Quote cbondeson Quote  Post ReplyReply Direct Link To This Post Topic: StoredProcQuery
    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?
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
cbondeson View Drop Down
Newbie
Newbie


Joined: 23-Jul-2010
Posts: 2
Post Options Post Options   Quote cbondeson Quote  Post ReplyReply Direct Link To This Post 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.


Edited by cbondeson - 24-Jul-2010 at 5:34am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down