当前位置:网站首页>EF杂项
EF杂项
2022-07-21 15:01:00 【威威当爸了】
Context.Entry<Job>(job).State = System.Data.Entity.EntityState.Modified;//更新
//Job类型
//job对象
EF超时问题
//连接超时
Connection Timeout=60;//加在连接字符串中
//执行超时
_test.Database.CommandTimeout = 180;
EF处理 数据库中 null的问题
var query=from f in db.tb_flag
where Nullable<int>.Equals(f.flag,null) select f;
//生成的SQL语句为 where flag is null
//将连接字符串写在程式中
public Context()//上下文的构造函数中直接写上对应信息,然后就可以删除app.config/web.config
: base("server=WAYLIPC;database=Programme;uid=sa;pwd=1987214li;")
{
}
//linq包含查寻
List<CodeFirst.ProductReCord> tt = _context.ProductReCords.Where(o => new int[] { 1, 2,3,4,5,6 }.Contains(o.Id)).ToList();
//==sql
SELECT * FROM dbo.ProductReCord WHERE Id IN (1,2,3,4,5,6)
//Linq模糊查寻
var ct=_context.ProductReCords.Where(o => o.FileName.StartsWith("a") && o.FileName.EndsWith("t")&&o.FileName .Contains("abc")).Select(o=>new {o.Id,o.FileName,o.JobNum ,o.Check_Sum});
//StartsWith 匹配开始字符串 a%
//EndsWith 匹配结束字符串 %a
//Contains 包含 %a%
下面是sql
SELECT
[Extent1].[Id] AS [Id],
[Extent1].[FileName] AS [FileName],
[Extent1].[JobNum] AS [JobNum],
[Extent1].[Check_Sum] AS [Check_Sum]
FROM [dbo].[ProductReCord] AS [Extent1]
WHERE ([Extent1].[FileName] LIKE 'a%') AND ([Extent1].[FileName] LIKE '%t') AND ([Extent1].[FileName] LIKE '%abc%')
边栏推荐
猜你喜欢
吉时利Keithley软件2600系列2635B|2636B|2651A|2657A NS-SourceMeter源表软件
Chrome升级到80版本遇到的问题-系统登录不了的解决方法
Automatic test software faster than LabVIEW, atecloud cloud test platform evaluation
Deep understanding of perfect hash
直播回顾| Apache Pulsar Meetup 精彩回放(含 PPT 下载)
深入理解Redux中间件的原理
HTC手机如何进行官方解锁Unlock
vi编辑器常用命令
Keithley software 2600 series 2601b | 2602b | 2604b | 2606b ns SourceMeter source table software
【FAQ】应用内支付服务无法拉起支付页面常见原因分析和解决方法
随机推荐
【MySQL和数据库】MySQL & database 第十章:函数的学习
IP address classification and range
jsp自定义标签库--foreach
Gaussian membership function instruction of PLC Fuzzy Control Series
Node项目中使用jsonwebtoken实现JWT认证
【FAQ】应用内支付服务无法拉起支付页面常见原因分析和解决方法
How can elastic group by intercepting the values of fields?
[iccv 2019] acnet: using asymmetric convolution blocks to enhance CNN's convolution kernel skeleton
Is the income of fixed income financial products certain?
ECCV 2022 oral "unicorn" unifies the network structure and learning paradigm of four target tracking tasks for the first time, and SOTA on eight challenging data sets
Qt - vue graphique
In the classic mode of dynamics CRM 365 OP version, the tab is scrolled. Can it be displayed through the tab like the UCI interface
OS实验五 基于内核栈切换的进程切换
Keithley software 2600 series 2635b | 2636b | 2651a | 2657a ns SourceMeter source table software
QML编码规范
UE4 learning notes checkbox instead of button + image
Determine the position of an element in an array, and move all subsequent values backward after insertion
js实现一个Promises/A+ 规范的Promise
Join hands with HMS core analysis services to help the efficient growth of games with data
Unity 3D modify default editor