具有自定义结果表的实体框架核心相关数据

编程入门 行业动态 更新时间:2024-10-27 20:32:30
本文介绍了具有自定义结果表的实体框架核心相关数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的项目是使用asp核心1.1的电厂预算控制系统 我的模型如下所示: 公共课BudgetAuthority { public int ID {get;组; }¥b $ b [必填] 公共字符串 AuthorityName {get;组; }¥b $ b public virtual ICollection< REHPViewModelData> REHPData {get;组; }¥b $ b } 公共类BudgetHead { public int ID {get;组; }¥b $ b [必填] 公共字符串BudgetHeadName {get;组; }¥b $ b [必填] 公共字符串BudgetHeadDescription {get;组; }¥b $ b public virtual ICollection< REHPViewModelData> REHPData {get;组; }¥b $ b } 公共课BudgetEear { public int ID {get;组; }¥b $ b [必填] public string BudgetYearName {get;组; }¥b $ b 公共虚拟ICollection< BudgetYearlyAllocation> BudgetYearlyAllocation {get;组; }¥b $ b public virtual ICollection< REHPViewModelData> REHPData {get;组; }¥b $ b } 公共课BudgetYearlyAllocation { public int ID {get;组; }¥b $ b [必填] [DisplayFormat(DataFormatString =" {0:N}")] 公共十进制AllocatedAmount {get;组; }¥b $ b public int BudgetYearID {get;组; }¥b $ b [ForeignKey(" BudgetYearID")] $ public virtual BudgetYear BudgetYear {get;组; }¥b $ b public int PowerPlantID {get;组; }¥b $ b [ForeignKey(" PowerPlantID")] $ 公共虚拟PowerPlants PowerPlants {get;组; }¥b $ b } 公共级PowerPlants { public int ID {get;组; }¥b $ b [必填] public string PowerPlantName {get;组; }¥b $ b public virtual ICollection< REHPViewModelData> REHPData {get;组; }¥b $ b 公共虚拟ICollection< BudgetYearlyAllocation> BudgetYearlyAllocation {get;组; }¥b $ b public virtual ICollection< ApplicationUser> ApplicationUser {get;组; }¥b $ b }¥b $ b 公共课WorkCategories { public int ID {get;组; }¥b $ b [必填] public string WorkCategoriesName {get;组; }¥b $ b public virtual ICollection< REHPViewModelData> REHPData {get;组; }¥b $ b } 公共类REHPViewModelData { public int ID {get;组; } [必填] [DisplayFormat(DataFormatString =" {0:N}")] 公共小数ApprovedAmount {get;组; }¥b $ b public int PowerPlantID {get;组; }¥b $ b [ForeignKey(" PowerPlantID")] $ 公共虚拟PowerPlants PowerPlants {get;组; }¥b $ b public int BudgetHeadID {get;组; }¥b $ b [ForeignKey(" BudgetHeadID")] $ 公共虚拟BudgetHead BudgetHead {get;组; } public int WorkCategoriesID {get;组; }¥b $ b [ForeignKey(" WorkCategoriesID")] $ public virtual WorkCategories WorkCategories {get;组; } public int AuthorityID {get;组; }¥b $ b [ForeignKey(" AuthorityID")] $ 公共虚拟BudgetAuthority BudgetAuthority {get;组; }¥b $ b public int BudgetYearID {get;组; }¥b $ b [ForeignKey(" BudgetYearID")] $ public virtual BudgetYear BudgetYear {get;组; }¥b $ b }¥b $ b $ $ 示例 BudgetAuthority表格数据是&bbsp; b ID 权威名称 1 MD 2 GM $ 示例BudgetHead表数据是&bbsp; b $ ID BudgetHeadName BudgetHeadDescription 1 A / budget 计划旅行 2 B /预算 乘车旅行 3 C /预算 旅行用于运送 示例 BudgetYear Table数据是&bbsp; b ID BudgetYearName 1 2017年¥b $ b 2 2018年 3 2019年 示例BudgetYearlyAllocation表数据是 ID AllocatedAmount BudgetYearID PowerPlantID 1 1000 1 1 2 900 1 2 3 800 1 3 示例 PowerPlants表数据为 ID PowerPlantName 1 PowerStationOne 2 PowerStationTwo 3 PowerStationThree ¥b $ b示例工作类别表数据是 ID WorkCategoriesName 1 电气 2 民事 3 机械 4 一般 我想要表结果只有预算年度和电厂数据详细信息表数据示例ind sql数据库数据为$ ID(1)BudgetYearIDColumn(2)PowerPlantIDColumn (3)TotalElectricalAmountColumn (4)Nos (5)TotalMechnicalColumn (6)第 (7)TotalCivilColumn (8)编号(6)TotalGeneralColumn (9)Nos (10)TotalAmountColumn (11)AllocatedAmountOfBudgetYearlyAllocationTablewithPowerPlantID - (10)TotalAmount列 (12)&MDAuthorityNosColumn NBSP; (13)GMAuthorityNosColumn 1 1 1 100 3 100 2 200 1 100 5 500 1000-500 = 500 8 3 2 1 2 100 3 100 2 200 1 100 5 500 900-500 = 400 8 3 3 1 3 100 3 100 2 200 1 100 5 500 800-500 = 300 8 3 $ Index.chtml结果看起来像这样 - ID(1)BudgetYearIDColumn(2)PowerPlantIDColumn (3)TotalElectricalAmountColumn (4)Nos (5)TotalMechnicalColumn (6)第 (7)TotalCivilColumn (8)编号(6)TotalGeneralColumn (9)Nos (10)TotalAmountColumn (11)AllocatedAmountOfBudgetYearlyAllocationTablewithPowerPlantID - (10)TotalAmount列 (12)&MDAuthorityNosColumn NBSP; (13)GMAuthorityNosColumn 1 2017 PowerPlantOne 100.00 3 100.00 2 200.00 1 100.00 5 500.00 500.00 8 3 2 2017 PowerPlantTwo 100.00 3 100.00 2 200.00 1 100.00 5 500.00 400.00 8 3 3 2017 PowerPlantThree 100.00 3 100.00 2 200.00 1 100.00 5 500.00 300.00 8 3 请帮我这个结果表可以在REHPViewModelData中显示 模型和 REHPViewModelData不包含BudgetAllocation表,但没有关系和现在分类的REHPViewModelData列和BudgetAuthority列,包含关系类别和预算权限表。结果表 sperate categories列和ButgetAuthority列中的。如何进行新的模型设计和编码谢谢。 $

解决方案

social.msdn.microsoft/Forums/en-US/home? forum = adodotnetentityframework

这是你应该发布的地方。

My project is Power Plant Budget Control System with asp core 1.1 My Models is look like this: public class BudgetAuthority { public int ID { get; set; } [Required] public string AuthorityName { get; set; } public virtual ICollection<REHPViewModelData> REHPData { get; set; } } public class BudgetHead { public int ID { get; set; } [Required] public string BudgetHeadName { get; set; } [Required] public string BudgetHeadDescription { get; set; } public virtual ICollection<REHPViewModelData> REHPData { get; set; } } public class BudgetYear { public int ID { get; set; } [Required] public string BudgetYearName { get; set; } public virtual ICollection<BudgetYearlyAllocation> BudgetYearlyAllocation { get; set; } public virtual ICollection<REHPViewModelData> REHPData { get; set; } } public class BudgetYearlyAllocation { public int ID { get; set; } [Required] [DisplayFormat(DataFormatString = "{0:N}")] public decimal AllocatedAmount { get; set; } public int BudgetYearID { get; set; } [ForeignKey("BudgetYearID")] public virtual BudgetYear BudgetYear { get; set; } public int PowerPlantID { get; set; } [ForeignKey("PowerPlantID")] public virtual PowerPlants PowerPlants { get; set; } } public class PowerPlants { public int ID { get; set; } [Required] public string PowerPlantName { get; set; } public virtual ICollection<REHPViewModelData> REHPData { get; set; } public virtual ICollection<BudgetYearlyAllocation> BudgetYearlyAllocation { get; set; } public virtual ICollection<ApplicationUser> ApplicationUser { get; set; } } public class WorkCategories { public int ID { get; set; } [Required] public string WorkCategoriesName { get; set; } public virtual ICollection<REHPViewModelData> REHPData { get; set; } } public class REHPViewModelData { public int ID { get; set; } [Required] [DisplayFormat(DataFormatString = "{0:N}")] public decimal ApprovedAmount { get; set; } public int PowerPlantID { get; set; } [ForeignKey("PowerPlantID")] public virtual PowerPlants PowerPlants { get; set; } public int BudgetHeadID { get; set; } [ForeignKey("BudgetHeadID")] public virtual BudgetHead BudgetHead { get; set; } public int WorkCategoriesID { get; set; } [ForeignKey("WorkCategoriesID")] public virtual WorkCategories WorkCategories { get; set; } public int AuthorityID { get; set; } [ForeignKey("AuthorityID")] public virtual BudgetAuthority BudgetAuthority { get; set; } public int BudgetYearID { get; set; } [ForeignKey("BudgetYearID")] public virtual BudgetYear BudgetYear { get; set; } } Example BudgetAuthority Table data is ID AuthorityName 1 MD 2 GM Example BudgetHead Table data is ID BudgetHeadName BudgetHeadDescription 1 A/budget Travelling for Plan 2 B/budget Travelling for Car 3 C/budget Travelling for Shipping Example BudgetYear Table data is ID BudgetYearName 1 2017 2 2018 3 2019 Example BudgetYearlyAllocation Table data is ID AllocatedAmount BudgetYearID PowerPlantID 1 1000 1 1 2 900 1 2 3 800 1 3 Example PowerPlants Table Data is ID PowerPlantName 1 PowerStationOne 2 PowerStationTwo 3 PowerStationThree Example WorkCategories Table data is ID WorkCategoriesName 1 Electrical 2 Civil 3 Mechanical 4 General I want Table result of Only Budget years and power plant data details Table data example ind sql database data is ID (1)BudgetYearIDColumn (2)PowerPlantIDColumn (3)TotalElectricalAmountColumn (4)Nos (5)TotalMechnicalColumn (6)Nos (7) TotalCivilColumn (8)Nos (6)TotalGeneralColumn (9)Nos (10)TotalAmountColumn (11) AllocatedAmountOfBudgetYearlyAllocationTablewithPowerPlantID – (10)TotalAmount Column (12)MDAuthorityNosColumn (13)GMAuthorityNosColumn 1 1 1 100 3 100 2 200 1 100 5 500 1000-500=500 8 3 2 1 2 100 3 100 2 200 1 100 5 500 900-500=400 8 3 3 1 3 100 3 100 2 200 1 100 5 500 800-500=300 8 3 Index.chtml result is looklike this- ID (1)BudgetYearIDColumn (2)PowerPlantIDColumn (3)TotalElectricalAmountColumn (4)Nos (5)TotalMechnicalColumn (6)Nos (7) TotalCivilColumn (8)Nos (6)TotalGeneralColumn (9)Nos (10)TotalAmountColumn (11) AllocatedAmountOfBudgetYearlyAllocationTablewithPowerPlantID – (10)TotalAmount Column (12)MDAuthorityNosColumn (13)GMAuthorityNosColumn 1 2017 PowerPlantOne 100.00 3 100.00 2 200.00 1 100.00 5 500.00 500.00 8 3 2 2017 PowerPlantTwo 100.00 3 100.00 2 200.00 1 100.00 5 500.00 400.00 8 3 3 2017 PowerPlantThree 100.00 3 100.00 2 200.00 1 100.00 5 500.00 300.00 8 3 Please help me this result table can be show in REHPViewModelData Model and REHPViewModelData is not include BudgetAllocation table with not relationship and now REHPViewModelData of Categroeis column and BudgetAuthority Column with relationship Categories and Budget Authority Tables.Result table in sperate categories columns and ButgetAuthority Columns. How to do new model design and coding thank.

解决方案

social.msdn.microsoft/Forums/en-US/home?forum=adodotnetentityframework

it is where you should post.

更多推荐

具有自定义结果表的实体框架核心相关数据

本文发布于:2023-11-12 04:53:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580558.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   实体   框架   核心   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!