如何在运行时编写具有各种参数的Get方法?

时间:2019-03-06 10:44:57

标签: asp.net-core .net-core core-api

我想用存储库方法编写一个api,其中一个实体表包含三个实体的地址。

这是实体关系表:

public partial class Addresses
{
    public Guid Id { get; set; }
    public Guid? SchoolHeadOfficeId { get; set; }
    public Guid? SchoolsId { get; set; }
    public Guid? UserId { get; set; }
}

我的IRespository是这样的:

public interface IAddressesRepositry
{
    Task<Addresses> GetAllAddressesByUSerIdAsync(Guid Id);
    Task<Addresses> CreateAddressesAsync(Addresses addresses);
}

我想在我的存储库类中做一些事情:

public class AddressesRepositry : IAddressesRepositry
{

    learning_gpsContext _learning_GpsContext = null;
    public AddressesRepositry(learning_gpsContext context)
    {
        _learning_GpsContext = context;
    }

    public Task<Addresses> GetAllAddressesByIdAsync(Guid SchoolHeadOfficeId , Guid SchoolsId, Guid UserId)
    {
        Addresses var = await _learning_GpsContext.Addresses.where(x => x.SchoolHeadOfficeId == schoolsystemId |or| SchoolsId==SchoolsId |or| UserId==UserId ) //here i will be unable to understand which 
                                                                            //type code can write to get data on the basis of any one id
       }
}

0 个答案:

没有答案