// DbConsts.Procedure.PROC_NAME_KEY 仓储过程名称
// 第二个参数为存储过程的参数
_procEntityRepository.FromSql(DbConsts.Procedure.PROC_NAME_KEY, new (){});
_testRepository.SqlProcedureQuery<PROC_Entity>("存储过程名"
, new ProcModel(){ Name = "Hoa", Age = 27 });
using Hoa.DbManager.Attributes;
using System;
using System.Collections.Generic;
using System.Text;
namespace Hoa.Core.Utilities.Entities
{
public class ProcModel
{
// 可以指定存储过程实际参数名
[ProcedureParameter("ACCOUNT_NAME")]
public string Name { get; set; }
public string Age { get; set; }
}
}
using Microsoft.EntityFrameworkCore;
using System;
using Hoa.Core;
namespace Hoa.EntityFrameworkCore
{
public partial class HoaDbContext
{
// VIEW_Entity 是视图返回值对应的实体模型
public virtual DbSet<VIEW_Entity> VIEW_Entities { get; set; }
partial void OnModelCreatingPartial(ModelBuilder modelBuilder)
{
// 配置视图无键实体模型
modelBuilder.Entity<PROC_Entity>(entity =>
{
entity.HasNoKey();
// 通常我们需要将视图名称作为常量定义起来
// 这里的视图配置在 Hoa.Core.DbConsts.cs 文件中
entity.ToView(DbConsts.TableView.VIEW_NAME_KEY);
});
}
}
}