question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plain sql as IQueryable

See original GitHub issue

Hello,

is ist possible to write a Query<T>(string) and return a IQueryable istead of executing it directly?

        [Table("CUSTOMER")]
	public partial class Customer
	{
		[Column("ID"), PrimaryKey,  NotNull] public int    Id { get; set; } 
		[Column(), NotNull] public string Name { get; set; } 
		[Column(),  NotNull] public string FirstName { get; set; } 
		[Column(), Nullable         ] public string Company { get; set; } 
		[Column(),  NotNull] public string ZipCode { get; set; }
		[Column(), NotNull] public string Town { get; set; }
	}

       using(var dbContext = new MyDbContext()){
          var customers = dbContext.Query<Customer>("select c.* from CUSTOMER").Where(c => c.FirstName != null);
          var result = customers.ToList();
       }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sdanylivcommented, Nov 2, 2018

@Franki1986, will handle this.

0reactions
MaceWinducommented, Feb 1, 2019

closed by #1388

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mixing raw SQL with IQueryable for dynamic filter
In entity framework 6 is it possible to mix raw SQL generated dynamically with IQueryable like this: IQueryable<Tree> tree_query = context.Trees ...
Read more >
combining raw sql with IQueryable
I am creating queries from raw sql like this: (). var query = "SELECT * from ORDERS o where o.Year in (:orderYear));";. var...
Read more >
SQL Queries - EF Core
Entity Framework Core allows you to drop down to SQL queries when working with a relational database. SQL queries are useful if the...
Read more >
Explain IEnumerable and IQueryable and how EF query works
IQueryable objects hold a reference to the underlying query provider (IQueryProvider type). When you materialize your query by iterating or ...
Read more >
Execute Raw SQL Queries in Entity Framework Core
Entity Framework Core provides the DbSet.FromSql() method to execute raw SQL queries for the underlying database and get the results as entity objects....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found