コード例 #1
0
    public static IQueryable <T> WithHints <T>(this DbSet <T> dbSet, DbHint primaryHint, params DbHint[] hints)
        where T : class
    {
        var hintFormatter = dbSet.GetInfrastructure().GetService <IDbHintFormatter>();

        if (hintFormatter == null)
        {
            return(dbSet);
        }
        var tableName = dbSet.GetTableName();
        var mHints    = MemoryBuffer <DbHint> .Lease(false);

        try {
            mHints.Add(primaryHint);
            mHints.AddSpan(hints.AsSpan());
            if (mHints.Count == 0)
            {
                return(dbSet);
            }
            var sql = hintFormatter.FormatSelectSql(tableName, ref mHints);
            return(dbSet.FromSqlRaw(sql));
        }
        finally {
            mHints.Release();
        }
    }
コード例 #2
0
 public static Exception UnsupportedDbHint(DbHint hint)
 => new NotSupportedException($"Unsupported DbHint: {hint}");