根据组合框的选择保存在数据库的不同表中 [英] save in different tables in the database based on the selection of a combobox
本文介绍了根据组合框的选择保存在数据库的不同表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须创建传递具有一对多关系的实体的通用视图模型.我将解释:我的窗口:
<Window x:Class="Invoice_Example_Brux.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:invoiceExampleBrux="clr-namespace:Invoice_Example_Brux"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<invoiceExampleBrux:MainWindowViewModel/>
</Window.DataContext>
<Grid>
<TextBox HorizontalAlignment="Left" Height="23" Margin="174,78,0,0" TextWrapping="Wrap" Text="{Binding MyModel.Name}" VerticalAlignment="Top" Width="120"/>
<Label Content="Id" HorizontalAlignment="Left" Margin="10,53,0,0" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="10,78,0,0" TextWrapping="Wrap" Text="{Binding MyModel.Id}" VerticalAlignment="Top" Width="120" IsReadOnly="True"/>
<Label Content="Number" HorizontalAlignment="Left" Margin="322,52,0,0" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="322,78,0,0" TextWrapping="Wrap" Text="{Binding MyModel.Number}" VerticalAlignment="Top" Width="120"/>
<Label Content="Name" HorizontalAlignment="Left" Margin="174,53,0,0" VerticalAlignment="Top"/>
<Button Content="Save" HorizontalAlignment="Left" Margin="211,288,0,0" VerticalAlignment="Top" Width="75" Command="{Binding SaveCommand}"/>
<ComboBox
SelectionChanged="Selector_OnSelectionChanged"
HorizontalAlignment="Left" Margin="180,38,0,0" VerticalAlignment="Top" Width="120"
DisplayMemberPath="Name"
ItemsSource="{Binding DocumentType,UpdateSourceTrigger=PropertyChanged}"/>
<Label Content="Type Document" HorizontalAlignment="Left" Margin="192,12,0,0" VerticalAlignment="Top"/>
</Grid>
myWindows codebheind:
myWindows codebheind:
推荐答案
向大家问好,
我找不到最终目标的合适解决方案.
在风景优美的MVVM中.
我有一个窗口(用于插入票据的窗口)是一个组合框,可以在其中选择发票类型(即时发票,递延发票,运输单据,报价,交货单等).
并且我将在db中有各自的表(head和body).
现在,根据您的选择,我可以将数据保存在相关表中.我无法首先在WPF MVVM解决方案实体框架代码中实现它.
=(而且花了几个月的时间,但无济于事.我现在要解决此问题,我在救援前使用了自动映射器,即做了映射表.
我将一个链接链接到我想在wpf上复制的视频.
视频
我希望获得帮助.
hello to all,
I could not find a suitable solution to my final goal.
are in a scenery MVVM.
I have a window (the one for inserting bills) in this window is a combobox where I can choose the types of invoice (invoice immediate, deferred invoice, transport document, quotation, delivery order etc ...)
and I'll have the respective tables in the db (head and body).
Now I do based on your choice I can save the data in the related tables. I was not able to implement it in my WPF MVVM solution entity framework code first.
= (And for a few months but to no avail. I do for now to work around this problem, I used automapper ie before the rescue and did the mapping table.
I put a link to a video of what I would like to replicate on wpf.
video
I'm hoping for some help.
这篇关于根据组合框的选择保存在数据库的不同表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文