none
How to create new record in entity framework from NewItemPlaceholder RRS feed

  • Вопрос

  • Hello all!

    DataGrid defined as follows:

    <DataGrid ItemsSource = "{Binding masterView}"...>

    Where 

            private CollectionView _masterView;
            public CollectionView masterView
            {
                get
                {
                    if (_masterView == null)
                        GetMasterEntityCollection();
                    return _masterView;
                }
            }
    

    On click Add button, after input info in NewItemPlaceHolder in bottom of datagrid I try save it as follows:

    private void AddData()
     {
       obj_type newIt = (obj_type)_masterView.CurrentItem;
       dc.AddObject("obj_types", newIt);
       dc.SaveChanges();
    }
    
    

    but I get error message:

    "Unable to cast object of type 'MS.Internal.NamedObject' to type 'EF.obj_type'."

    How I can save NewItemPlaceHolder in entity?

    Thanks in advance!

    12 февраля 2013 г. 9:01

Ответы

Все ответы