C# MVC Model view connecting 2 different database columns

半世苍凉 提交于 2021-01-29 15:20:58

问题


This is the first time I have attempted to join information from one database to the other. I have a accounting database and a regular site database. Trying to keep them separate. I have a page that shows Transactions but am getting the information for a few of the columns from the regular database by way of Id's. Below is my Model. I am showing nothing in the fields for the items in the other database.

    public class Transaction
{
    [Key]
    public Guid TransactionId { get; set; }
    public string Description { get; set; }
    public int? CompanyId { get; set; }
    public Guid? VendorId { get; set; }
    public string InCheckNumber { get; set; }
    public string OutCheckNumber { get; set; }
    public string InvoiceNumber { get; set; }
    public string PurchaseOrderNumber { get; set; }
    public Guid LedgerAccountId { get; set; }
    public decimal? DebitAmount { get; set; }
    public decimal? CreditAmount { get; set; }
    public DateTime TransactionDate { get; set; }
    public string ModifiedBy { get; set; }
    public DateTime? ModifiedDate { get; set; }
    public string SavedDocument { get; set; }
    public DateTime CreatedDate { get; set; }
    public string CreatedBy { get; set; }
    public bool IsCredit { get; set; }
    public bool IsDebit { get; set; }
    public Guid Type { get; set; } 

    [ForeignKey("LedgerAccountId")]
    public LedgerAccount LedgerAccount { get; set; }
    [ForeignKey("CompanyId")]
    public CompanyNames Company { get; set; }
    [ForeignKey("VendorId")]
    public Vendors Vendor { get; set; }

}

I have added the 'using' of the General.Entities to this model. Is there something else i need to add for this?

Thanks in advance.

UPDATE: See Question - Link to answer of question

来源:https://stackoverflow.com/questions/65619557/c-sharp-mvc-model-view-connecting-2-different-database-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!