Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to use FromSql() with a type that is not necessarily a DbSet? #4653

Closed
csaloio opened this issue Feb 26, 2016 · 1 comment
Closed

Comments

@csaloio
Copy link

csaloio commented Feb 26, 2016

If I want to execute a simple query such as listing the names of the roles in a role table I can do this:

var sql = "SELECT r.name FROM com.role r";
return _ctx.Roles.AsNoTracking().FromSql(sql).Select(r => r.name).ToList();

Which will produce SQL like:

 SELECT "r"."name"
      FROM (
          SELECT r.name FROM com.role r
      ) AS "r"

It would be nice if I could instead do something like this:

var sql = "SELECT r.name FROM com.role r";
return _ctx.FromSql<string>(sql).ToList();

so that the result set doesn't have to map to a type setup as a DbSet in the context. Is this possible or something you'd consider adding in some way?

@csaloio csaloio changed the title Possible to use FromSql() with a type that is not necessaily a DbSet? Possible to use FromSql() with a type that is not necessarily a DbSet? Feb 26, 2016
@divega
Copy link
Contributor

divega commented Feb 26, 2016

Dupe of #1862.

@csaloio csaloio closed this as completed Feb 26, 2016
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants