简体   繁体   中英

Create temp table with Entity Framework

I want to create a temp table in sql server by using Entity Framework. Is there any way I can do this? If I can create a temp table, my next question is, how I can read it?

Thanks in advance.

André

Ok, so you don't like the stored procedures route....nor do I to be honest, but it's the quickest way I could think of doing it.

Based on that, I don't know of any easy way in EDM to create temp tables so my next suggestion would be to create local objects, which mimic the temporary table you wish to create. The name temporary obviously indicates you don't want them to live on the database indefinitely, so using in memory objects has the benefit of being much more controllable and (depending on your latency) quicker than making multiple calls to a database.

public class MyTempTable
{
    public string ID { get; set; }
    public string Column1 { get; set; }
    // your other columns here
}

List<MyTempTable> tempTable = new List<MyTempTable>();

Once you've created your list of objects you can do basically anything you'd normally do on the database table using Linq.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM