locked
Entity Framework Child Entity On Gridview Only Count & Is Read Only RRS feed

  • Question

  • Hi,

    I have Product & ProductBOM In Entity Framework When I add Drag from Datasource the grid view only shows Count & Is Read Only Column, I have also tried manually assigning datsource but still not working.


    Thanks & Regards, Vinay Suryawomshi

    Wednesday, October 31, 2012 2:45 PM

Answers

  • This is the workaround i found 

    Added New Class with Name ObservableListSource below is the code

    Imports System.Collections
    Imports System.Collections.Generic
    Imports System.Collections.ObjectModel
    Imports System.ComponentModel
    Imports System.Diagnostics.CodeAnalysis
    Imports System.Data.Entity


    Public Class ObservableListSource(Of T As Class)
        Inherits ObservableCollection(Of T)
        Implements IListSource
        Private _bindingList As IBindingList

        Private ReadOnly Property ContainsListCollection() As Boolean Implements IListSource.ContainsListCollection
            Get
                Return False
            End Get
        End Property

        Private Function GetList() As IList Implements IListSource.GetList
            Return If(_bindingList, (InlineAssignHelper(_bindingList, Me.ToBindingList())))
        End Function
        Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
            target = value
            Return value
        End Function
    End Class

    Workaround

    It is working  but i dont know about ripple effects. 


    Thanks & Regards, Vinay Suryawomshi

    Saturday, November 10, 2012 11:05 AM

All replies

  • Hi;

    Please make sure that all tables have a Primary Key defined in the database.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Wednesday, October 31, 2012 3:04 PM
  • Hi,

    I have checked all the tables have primary key


    Thanks & Regards, Vinay Suryawomshi

    Wednesday, October 31, 2012 3:12 PM
  • Sorry that is about the only thing I can think of that would cause the issue.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Wednesday, October 31, 2012 4:07 PM
  • thanks for trying to help me

    Thanks & Regards, Vinay Suryawomshi

    Wednesday, October 31, 2012 4:30 PM
  • Same problem here with EF5 ,I had to return to EF4 , i wish someone from MS to recognize this bug and tell us what to do ? i left same question up in the thread

    Regards


    • Edited by Bassam, EG Thursday, November 1, 2012 2:33 PM
    Thursday, November 1, 2012 2:33 PM
  • Is it working fine in EF4 for you

    Thanks & Regards, Vinay Suryawomshi

    Thursday, November 1, 2012 4:37 PM
  • Yes, EF4 works fine , i use it since VS2010 is out that way , you drag the child entity into the grid all columns are there naturally, this is clearly a bug in EF5 !
    Thursday, November 1, 2012 8:49 PM
  • I tried downgrading it to 4.3 but no luck, is it something to do with VS2012 ?

    ChildGrid


    Thanks & Regards, Vinay Suryawomshi

    Friday, November 2, 2012 10:58 AM
  • Hi Vinay Suryawomshi,

    I have tested and I can repro the issue. If I use VS2012+EF5.0, the same issue with you occurs, but VS2010+EF5.0 works well. I will involve my workmates to research on this issue, it may need some time, thanks for your understanding.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, November 5, 2012 3:34 AM
  • Hi Vinay Suryawomshi,

    In VS2012, the default code generation strategy is using DbContext Template, please click anywhere of the edmx file and look at the Properties Window, change the "Code Generation Strategy" to "Default".

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, November 6, 2012 3:34 AM
  • but what if we need to use the new DbContext ? where MS recommends it over ObjectContext going further ?

    Thursday, November 8, 2012 8:41 PM
  • It is nothing to do with Visual Studio i have tested it with VS2010 & Entity Framework 5.0 with DBContext the same problem persist. I have also saw a issue in codeplex here is thew link http://entityframework.codeplex.com/workitem/639. But I dont understand the workaround.


    Thanks & Regards, Vinay Suryawomshi

    Saturday, November 10, 2012 10:19 AM
  • This is the workaround i found 

    Added New Class with Name ObservableListSource below is the code

    Imports System.Collections
    Imports System.Collections.Generic
    Imports System.Collections.ObjectModel
    Imports System.ComponentModel
    Imports System.Diagnostics.CodeAnalysis
    Imports System.Data.Entity


    Public Class ObservableListSource(Of T As Class)
        Inherits ObservableCollection(Of T)
        Implements IListSource
        Private _bindingList As IBindingList

        Private ReadOnly Property ContainsListCollection() As Boolean Implements IListSource.ContainsListCollection
            Get
                Return False
            End Get
        End Property

        Private Function GetList() As IList Implements IListSource.GetList
            Return If(_bindingList, (InlineAssignHelper(_bindingList, Me.ToBindingList())))
        End Function
        Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
            target = value
            Return value
        End Function
    End Class

    Workaround

    It is working  but i dont know about ripple effects. 


    Thanks & Regards, Vinay Suryawomshi

    Saturday, November 10, 2012 11:05 AM
  • Muchas gracias por tu aportación.

    Me sirvió mucho.

    thank.

    Wednesday, May 9, 2018 7:41 PM