2011-06-11 1 views
2

좋아, 얘야,이 말은 날 미치게 만든다. 나는 모든 페이지가 자식과 부모를 가질 수있는 페이지 구조를 나타내는 다음과 같은 (odata) 엔티티를 가지고있다. (기본적으로 모든 노드가 연결될 수있는 그래프). 데이터베이스에서는 두 개의 테이블 Page <-> PagePage <-> Page을 사용하여 다 대다 관계로 표현됩니다.OData 및 삽입 (AddLink) 다 - 대다 관계

Page Entity

문제는 내가 관계를 포함하여 새로운 개체를 삽입 단지 수 아니에요입니다. 내가 시도한 마지막 사항은 다음과 같습니다.

Page page = new Page() 
    { 
     Id = Guid.NewGuid(), 
     Title = "New Page", 
     Created = DateTime.Now, 
     LastChanged = DateTime.Now, 
     IsRedirected = false, 
     Position = 0, 
     Html = "Add your HTML here.", 
     Parent = { parent } 
    }; 

    this.Context.AddToPages(page); 
    this.Context.AddLink(parent, "Children", page); 
    parent.Children.Add(page); 
    this.Context.SaveChanges(); 

나는 다른 것을 시도 할 생각이 없습니다. 아무도 이것을 망 쳤어?

편집 1 : db diagram

편집 2 : 예외 정보 : 여기에 데이터베이스 다이어그램에서 사진의

System.Data.Services.Client.DataServiceRequestException was unhandled 
    Message=An error occurred while processing this request. 
    Source=System.Data.Services.Client 
    StackTrace: 
     at System.Data.Services.Client.DataServiceContext.SaveResult.HandleBatchResponse() 
     at System.Data.Services.Client.DataServiceContext.SaveResult.EndRequest() 
     at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options) 
     at System.Data.Services.Client.DataServiceContext.SaveChanges() 
     at PortfolioManagementConsole.Models.PageViewModel.SaveChanges(Object parameter) in C:\Users\Daniel\documents\visual studio 2010\Projects\PortfolioManagementService\PortfolioManagementConsole\Models\PageViewModel.cs:line 59 
     at PortfolioManagementConsole.Common.RelayCommand.Execute(Object parameter) in C:\Users\Daniel\documents\visual studio 2010\Projects\PortfolioManagementService\PortfolioManagementConsole\Common\RelayCommand.cs:line 52 
     at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated) 
     at System.Windows.Controls.Primitives.ButtonBase.OnClick() 
     at System.Windows.Controls.Button.OnClick() 
     at Telerik.Windows.Controls.RadButton.OnClick() in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\Buttons\RadButton.cs:line 348 
     at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) 
     at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e) 
     at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) 
     at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) 
     at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
     at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
     at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) 
     at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e) 
     at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) 
     at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) 
     at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
     at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
     at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) 
     at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) 
     at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) 
     at System.Windows.Input.InputManager.ProcessStagingArea() 
     at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) 
     at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) 
     at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) 
     at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
     at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
     at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
     at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 
     at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) 
     at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) 
     at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) 
     at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 
     at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) 
     at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) 
     at System.Windows.Threading.Dispatcher.Run() 
     at System.Windows.Application.RunDispatcher(Object ignore) 
     at System.Windows.Application.RunInternal(Window window) 
     at System.Windows.Application.Run(Window window) 
     at System.Windows.Application.Run() 
     at PortfolioManagementConsole.App.Main() in C:\Users\Daniel\documents\visual studio 2010\Projects\PortfolioManagementService\PortfolioManagementConsole\obj\x86\Debug\App.g.cs:line 0 
     at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     at System.Threading.ThreadHelper.ThreadStart() 
    InnerException: System.Data.Services.Client.DataServiceClientException 
     Message=<?xml version="1.0" encoding="utf-8" standalone="yes"?> 
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> 
    <code></code> 
    <message xml:lang="de-CH">An error occurred while processing this request.</message> 
</error> 
     Source=System.Data.Services.Client 
     StatusCode=500 
     StackTrace: 
      at System.Data.Services.Client.DataServiceContext.SaveResult.<HandleBatchResponse>d__1e.MoveNext() 
     InnerException: 
+0

어떤 오류가 발생합니까? 아니면 엔티티가 삽입되지 않은 것입니까? – svick

+0

context.SaveChanges() 메소드에 DataServiceRequestException이 있습니다. –

+0

그리고 예외 메시지? – svick

답변

0

귀하의 WCF 데이터 서비스 서버는 반환하지 않습니다 자세한 오류 메시지가와 그건 당신이 서버에서 반환 된 정확한 오류 메시지를 못 박는 것을 돕지 못합니다. 서버의 자세한 오류 메시지를 사용하려면 다음 지침을 따르십시오. http://blogs.msdn.com/b/phaniraj/archive/2008/06/18/debugging-ado-net-data-services.aspx. 이 기능을 사용하면 서버에서 발생하는 오류 메시지를 볼 수 있습니다.

모델을 볼 때, 아이부터 부모까지 다른 링크가 필요합니다. SaveChanges 코드 바로 앞에 다음 행을 추가하십시오.

this.Context.SetLink (page, "Parent", parent);

을 이해하는 데 도움이 더 나은, 여기 내 블로그에 몇 가지 링크는 어디에 사람이 협회는 WCF 데이터 서비스 클라이언트를 사용하여 작동하는 방법 I 세부 사항 : 많은 단체

http://blogs.msdn.com/b/phaniraj/archive/2008/10/23/working-with-associations-in-ado-net-data-services-part-2.aspx

1

1 1 협회에

http://blogs.msdn.com/b/phaniraj/archive/2008/07/02/working-with-relations-in-ado-net-data-services-beta-1.aspx