使用流畅映射的Entity Framework中的一对多(One to many in Entity Framework using fluent mapping)
我试图通过使用流畅的api做一对多的地图。 这是我的课程
public class Product : EntityBase { public Product() { this.ProductArticles = new List<ProductArticle>(); } [Key] public int ProductId { get; set; } public string Description { get; set; } public string ReportText1 { get; set; } public string ReportText2 { get; set; } public bool Standard { get; set; } public int ProductGroupId { get; set; } public decimal? Surcharge1 { get; set; } public decimal? Surcharge2 { get; set; } public decimal? Surcharge3 { get; set; } public decimal? Surcharge4 { get; set; } public decimal PriceIn { get; set; } public decimal PriceOut { get; set; } public decimal PriceArtisanIn { get; set; } public decimal PriceArtisanOut { get; set; } public decimal PriceTotalIn { get; set; } public decimal PriceTotalOut { get; set; } public decimal PriceTotalOutVat { get; set; } public decimal PriceAdjustment { get; set; } public bool Calculate { get; set; } public string Notes { get; set; } [ForeignKey("ProductGroupId")] public virtual ProductGroup ProductGroup { get; set; } public virtual ICollection<ProductArticle> ProductArticles { get; set; } } public class ProductArticle : EntityBase { [Key] public int ProductArticleId { get; set; } public int ProductId { get; set; } public int ArticleId { get; set; } public decimal Qty { get; set; } public decimal PriceIn { get; set; } public bool Primary { get; set; } public virtual Product Product { get; set; } public virtual Article Article { get; set; } }
现在我想从单个产品包括所有ProductArticles
这是我的映射
public class ProductMap : EntityTypeConfiguration<Product> { public ProductMap() { // Primary Key this.HasKey(p => p.ProductId); // Table & Column Mappings this.ToTable("Product"); this.HasMany(p => p.ProductArticles) .WithOptional() .Map(p => p.MapKey("ProductId").ToTable("ProductArticle")); }
但它不起作用..请帮忙:)
Im trying to do a one-to-many map by using fluent api. This is my classes
public class Product : EntityBase { public Product() { this.ProductArticles = new List<ProductArticle>(); } [Key] public int ProductId { get; set; } public string Description { get; set; } public string ReportText1 { get; set; } public string ReportText2 { get; set; } public bool Standard { get; set; } public int ProductGroupId { get; set; } public decimal? Surcharge1 { get; set; } public decimal? Surcharge2 { get; set; } public decimal? Surcharge3 { get; set; } public decimal? Surcharge4 { get; set; } public decimal PriceIn { get; set; } public decimal PriceOut { get; set; } public decimal PriceArtisanIn { get; set; } public decimal PriceArtisanOut { get; set; } public decimal PriceTotalIn { get; set; } public decimal PriceTotalOut { get; set; } public decimal PriceTotalOutVat { get; set; } public decimal PriceAdjustment { get; set; } public bool Calculate { get; set; } public string Notes { get; set; } [ForeignKey("ProductGroupId")] public virtual ProductGroup ProductGroup { get; set; } public virtual ICollection<ProductArticle> ProductArticles { get; set; } } public class ProductArticle : EntityBase { [Key] public int ProductArticleId { get; set; } public int ProductId { get; set; } public int ArticleId { get; set; } public decimal Qty { get; set; } public decimal PriceIn { get; set; } public bool Primary { get; set; } public virtual Product Product { get; set; } public virtual Article Article { get; set; } }
Now i want from single Product include all ProductArticles
This is my mapping
public class ProductMap : EntityTypeConfiguration<Product> { public ProductMap() { // Primary Key this.HasKey(p => p.ProductId); // Table & Column Mappings this.ToTable("Product"); this.HasMany(p => p.ProductArticles) .WithOptional() .Map(p => p.MapKey("ProductId").ToTable("ProductArticle")); }
But it doesnt work.. Please help :)
原文:https://stackoverflow.com/questions/18784294
最满意答案
还没有采用这个来解决我现在的PC /蓝牙通信问题(目前使用32feet和C#)但是我确实遇到了一个用于C ++的本地Microsoft库: https ://msdn.microsoft.com/en-us/library/ 窗户/桌面/ aa362932%28V = vs.85%29.aspx
正如我所说,我自己没有尝试过,所以不能保证,但它可能值得一看?
Not yet resorted to this for my own current PC/Bluetooth comms woes (currently working with 32feet and C#) however I did come across a native Microsoft library for C++: https://msdn.microsoft.com/en-us/library/windows/desktop/aa362932%28v=vs.85%29.aspx
As I say I've not tried it myself so can't vouch for it but it may be worth a look?
相关问答
更多-
在C#中查找本地蓝牙适配器的32Feet BluetoothAddress(Find 32Feet BluetoothAddress of local Bluetooth adapter in C#)[2022-04-10]
为可能面临类似情况的其他人发布此答案。 基本上要创建一个蓝牙端点,你需要一个有效的适配器蓝牙MAC地址。 要获取本地机器的本地蓝牙MAC地址,请使用 BluetoothRadio.PrimaryRadio.LocalAddress 所以上面的代码将需要更改为 public static BluetoothAddress GetBTMacAddress() { BluetoothRadio myRadio = BluetoothRadio.PrimaryRadio; ... -
例如,“E:23.txt”不是文件的有效路径。 永远记住你的斜线,它们非常重要! 因此,您可以从以下位置更改它: e32socket.bt_obex_send_file(address,channel,u"E:23.txt") 至 e32socket.bt_obex_send_file(address,channel,u"E:\\23.txt") 另外,我对bt_obex_receive不太熟悉,但你也想修复那条路径。 此外,您正在导入appuifw模块而不使用它。 除非您计划添加使用它的代码,否则导入 ...
-
32feet蓝牙c#当连接设备关闭时抛出异常?(32feet bluetooth c# which exception thrown when connected device switch off?)[2023-05-08]
应该发生异常:在20秒之后,然后执行下一个IO操作。 你在等那么久吗? 或者你的阅读电话是否归零? 请参阅https://32feet.codeplex.com/wikipage?title=Connected%20Property上的 #2 在我使用蓝牙进行的测试中,一台设备似乎需要大约20秒才能意识到其他设备已经消失 - 尽管这可能是可配置的。 这在蓝牙中称为“链路监控超时”。 因此,您必须等待很长时间才能让系统知道连接丢失,然后您将在下一次IO操作时发现如果您在没有接收到数据时开始读取,它将阻止直到连 ... -
解决方案很简单。 我只是忘了定期发送一份LifeSignMsg stream.Write(new byte[] { 0x02, 0x23, 0x00, 0x00, 0x03 }, 0, 5); The solution was simple. I just forgot to send a periodic LifeSignMsg like stream.Write(new byte[] { 0x02, 0x23, 0x00, 0x00, 0x03 }, 0, 5);
-
还没有采用这个来解决我现在的PC /蓝牙通信问题(目前使用32feet和C#)但是我确实遇到了一个用于C ++的本地Microsoft库: https ://msdn.microsoft.com/en-us/library/ 窗户/桌面/ aa362932%28V = vs.85%29.aspx 正如我所说,我自己没有尝试过,所以不能保证,但它可能值得一看? Not yet resorted to this for my own current PC/Bluetooth comms woes (curren ...
-
因此,对于SPP服务(RFCOMM),您可以使用您可能已经知道的UUID“00001101-0000-1000-8000-00805F9B34FB”,我正在使用它,它在115.2K波特率下工作正常。 然后在一个单独的线程中管理连接,如果你去Android的开发者门户 ,他们有一个解释的例子和协议的良好信息。 使用蓝牙API,Android应用程序可以执行以下操作: - 扫描其他蓝牙设备 - 为配对的蓝牙设备查询本地蓝牙适配器 - 建立RFCOMM通道 - 通过服务发现连接到其他设备 - 从其他设备传输数据 ...
-
设置32feet库(Setting up 32feet library)[2022-03-06]
也可能只是在Windows中没有打开蓝牙。 我使用的是.NET InTheHand库,并且只收到此消息,因为在Windows中关闭了BlueTooth,并通过激活BlueTooth解决了这个问题。 I just solved this. I think the problem was an old reference in my project to the NETCF version of the DLL from when I was trying to brute-force a solution, ... -
该问题与连接配对如何存储在注册表中无关。 事实证明,当你打开一个串口时,你需要让它稳定下来才能做任何事情。 理想情况下,只有在稳定后才会从“IsOpen”属性中获得真实,但是如果没有,则只需添加延迟... this.serialPort.Open(); // Delay to ensure that the serial port is in a stable state Thread.Sleep(StabilisationDelay ...
-
是否可以通过OBEX在不成对的设备之间传输文件?(Is it possible to transfer files via OBEX between unpaired devices?)[2022-11-02]
看起来在某些时候没有用户交互的配对是可能的,从这个判断: 在进行程序化配对时,如何避免或取消Android的蓝牙配对通知? 但是,看起来仍然出现了要求PIN的通知消息,他们无法解决这个问题。 OP所描述的基本方法似乎一直在研究2.3但我猜(并且希望,因为它充满了巨大的安全风险)它已不再存在了。 Looks like pairing without user interaction was possible at some point, judging by this: How can I avoid or ... -
蓝牙Obex使用brecham.obex上传和下载文件夹(Bluetooth Obex using brecham.obex upload and download of folder)[2023-03-25]
您只需列出文件夹/文件夹中的文件,然后单独上传/下载。 OBEX中没有其他功能。 You just have to list the files in the folder/folders and up-/download each individually. There are no other features in OBEX for this.