1.
dotnet add package Pomelo.EntityFrameworkCore.MySql
using Microsoft.EntityFrameworkCore; namespace ConsoleApp84 { internal class Program { static void Main(string[] args) { using(var context=new DbBookDataContext()) { List<int> idsList = new List<int>() { 100000000,200000000,300000000,400000000,500000000 }; var books = context.t1.Where(x => idsList.Contains(x.Id)).ToList(); foreach(var bk in books) { Console.WriteLine($"{bk.Id},{bk.FirstName},{bk.LastName}"); } } Console.ReadLine(); } } public class DbBookDataContext : DbContext { static readonly string connStr = "Server=localhost;user id=usernamevalue;password=passwordvalue;database=databasenamevalue"; //Mapped to table name,t1 public DbSet<Book> t1 { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseMySql(connStr, ServerVersion.AutoDetect(connStr)); } } public class Book { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } }
use mydb; select * from t1 where id in (100000000,200000000,300000000,400000000);
标签:used,string,get,C#,bk,Pomelo,EntityFrameworkCore,set,public From: https://www.cnblogs.com/Fred1987/p/18430142