-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional updates based on PR feedback
- Loading branch information
Showing
26 changed files
with
303 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 19 additions & 2 deletions
21
src/EntityFramework.Relational/RelationalDbSetExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,38 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using JetBrains.Annotations; | ||
using Microsoft.Data.Entity.Infrastructure; | ||
using Microsoft.Data.Entity.Query; | ||
using Microsoft.Data.Entity.Relational; | ||
using Microsoft.Data.Entity.Utilities; | ||
using Microsoft.Framework.DependencyInjection; | ||
|
||
// ReSharper disable once CheckNamespace | ||
|
||
namespace Microsoft.Data.Entity | ||
{ | ||
public static class RelationalDbSetExtensions | ||
{ | ||
public static RelationalDbSet<TEntity> AsRelational<TEntity>([NotNull]this DbSet<TEntity> dbSet) where TEntity :class | ||
public static IQueryable<TEntity> FromSql<TEntity>([NotNull]this DbSet<TEntity> dbSet, [NotNull]string query) where TEntity : class | ||
{ | ||
Check.NotNull(dbSet, nameof(dbSet)); | ||
Check.NotNull(query, nameof(query)); | ||
|
||
return new RelationalDbSet<TEntity>(dbSet); | ||
if (dbSet.Context.Database as RelationalDatabase == null) | ||
{ | ||
throw new InvalidOperationException(Strings.RelationalNotInUse); | ||
} | ||
|
||
var queryProvider = ((IAccessor<IServiceProvider>)dbSet).Service.GetRequiredService<EntityQueryProvider>(); | ||
|
||
var queryable = new EntityQueryable<TEntity>(queryProvider); | ||
queryable.AddAnnotation("Sql", query); | ||
|
||
return queryProvider.CreateQuery<TEntity>(Expression.Constant(queryable)); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.