首先我们说明一下ORM是什么。

微软官方提供的ORM工具,ORM让开发人员节省数据库访问的代码时间,将更多的时间放到业务逻辑层代码上。开发人员使用Linq语言,对数据库操作如同操作Object对象

一样省事。EF有三种使用场景,1. 从数据库生成Class,2.由实体类生成数据库表结构,3.通过数据库可视化设计器设计数据库,同时生成实体类。

ORM (对象关系型映射)是将数据存储从域对象自动映射到关系型数据库的工具。ORM主要包括3个部分:域对象、关系数据库对象、映射关系。ORM使类提供自动化CRUD,使

开发人员从数据库API和SQL中解放出来。以前是使用ADO.NET来进行对数据库中得数据表进行操作,现在,使用ORM直接对对象进行操作,操作对象就等于操作数据库表,

那怎么让对象和数据库表一一对应起来?这个过程就是通过ORM框架来完成的,操作对象就是操作数据库也是通过ORM来完成的。ORM框架就是做对象和数据库的映射的。

那么EntityFramework的作用是什么?

我的理解就是大大简化数据库操作的,举个例子:在没有使用EF前,我们要编写复杂的SQL语句,而使用了EF之后,将会减少编写复杂的SQL语句过程。

最终都是转化为SQL语句来执行。

下面说一下EF的使用,新建一个解决方案,添加一个项目EntifyFrameWork----->在项目下添加一个ADO.NET实体数据模型

然后选择一个数据库,测试连接没有问题后就可以了。

生成这样四个文件

数据库中的表就全部生成了

//------------------------------------------------------------------------------
// <auto-generated>
// 此代码是根据模板生成的。
//
// 手动更改此文件可能会导致应用程序中发生异常行为。
// 如果重新生成代码,则将覆盖对此文件的手动更改。
// </auto-generated>
//------------------------------------------------------------------------------ namespace EntityFrameWork
{
using System;
using System.Collections.Generic; public partial class Admins
{
public int LoginId { get; set; }
public string LoginPwd { get; set; }
public string AdminName { get; set; }
}
}

......

//------------------------------------------------------------------------------
// <auto-generated>
// 此代码是根据模板生成的。
//
// 手动更改此文件可能会导致应用程序中发生异常行为。
// 如果重新生成代码,则将覆盖对此文件的手动更改。
// </auto-generated>
//------------------------------------------------------------------------------ namespace EFDBDemo
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure; public partial class EFDBEntities : DbContext
{
public EFDBEntities()
: base("name=EFDBEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
} public DbSet<Admins> Admins { get; set; }
public DbSet<ScoreList> ScoreList { get; set; }
public DbSet<StudentClass> StudentClass { get; set; }
public DbSet<Students> Students { get; set; }
}
}
using System;
using System.Collections.Generic; using System.Linq;
using System.Text; using System.Data;
using System.Data.SqlClient; namespace EFDBDemo
{
class Program
{
#region EF的基本使用
//查询
static void Main(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
Students objStudent = efdb.Students.SingleOrDefault(s => s.StudentName == "冯小强");
if (objStudent != null)
{
Console.WriteLine(objStudent.StudentId + " " + objStudent.StudentName);
}
//用where()方法查询符合条件的数据
IQueryable<Students> query = efdb.Students.Where(s => s.StudentId > 100002);
Console.WriteLine("学号\t姓名\t年龄");
foreach (var item in query)
{
Console.WriteLine("{0}\t{1}\t{2}", item.StudentId, item.StudentName, item.Age);
}
Console.ReadKey();
} //添加
static void test01(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
efdb.Students.Add(new Students()
{
StudentAddress = "北京海淀区28号",
StudentName = "白富美",
StudentIdNo = 130223199210111213,
ClassId = 1,
Gender = "女",
Birthday = Convert.ToDateTime("1992-10-11"),
Age = 24,
PhoneNumber = "010-55662233"
});
int result = efdb.SaveChanges();
if (result == 1)
Console.WriteLine("添加成功!");
Console.ReadKey();
}
//修改
static void test02(string[] args)
{
EFDBEntities efdb = new EFDBEntities(); Students objStudent = efdb.Students.FirstOrDefault(s => s.StudentId == 100006);
objStudent.StudentAddress = "北京昭阳区";
objStudent.PhoneNumber = "13600000000";
int result = efdb.SaveChanges(); if (result == 1)
Console.WriteLine("修改成功!");
Console.ReadKey();
}
//删除
static void test03(string[] args)
{
EFDBEntities efdb = new EFDBEntities(); Students objStudent = efdb.Students.FirstOrDefault(s => s.StudentId == 100010);
efdb.Students.Remove(objStudent);//从集合中删除学员对象
int result = efdb.SaveChanges(); if (result == 1)
Console.WriteLine("删除成功!");
Console.ReadKey();
} #endregion #region Linq to Object //Linq to 字符串
static void test04(string[] args)
{
string strTest = "we are studying linq to object";
//定义查询表达式
var query = from c in strTest
select c;
//遍历查询结果并输出
foreach (char ch in query)
{
Console.WriteLine(ch);
}
Console.ReadLine();
} //Linq to List<T>
static void test05(string[] args)
{
List<Students> students = new List<Students>
{
new Students(){ StudentName="张浩明",Gender="男",Birthday=DateTime.Parse("1990-09-10")},
new Students(){ StudentName="李晓燕",Gender="女",Birthday=DateTime.Parse("1992-03-12")},
new Students(){ StudentName="郝云霄",Gender="女",Birthday=DateTime.Parse("1991-09-15") }
};
var stuList = from s in students where s.Gender == "女" select s;
foreach (var item in stuList)
{
Console.WriteLine(item.StudentName);
}
Console.ReadLine();
} //查询语句和查询方法对比
static void test06(string[] args)
{
string strTest = "We are studying Linq To Object"; //var query = from c in strTest
// where char.IsUpper(c)
// select c; var query = strTest.Where(c => char.IsUpper(c)); foreach (char ch in query)
{
Console.WriteLine(ch);
}
Console.ReadLine();
}
static void test07(string[] args)
{
List<Students> students = new List<Students>
{
new Students(){ StudentName="张浩明",Gender="男",Age=21},
new Students(){ StudentName="李晓燕",Gender="女",Age=23},
new Students(){ StudentName="张云霄",Gender="男",Age=20}
};
//查询姓张的男学生,并且按年龄升序排列
var stuList = from stu in students
where stu.StudentName.StartsWith("张") && stu.Gender == "男"
orderby stu.Age ascending
select stu;
//var stuList = students.Where(stu => stu.StudentName.StartsWith("张")
// && stu.Gender == "男")
// .OrderBy(stu => stu.Age); foreach (var item in stuList)
{
Console.WriteLine(item.StudentName + "\t" + item.Age);
}
Console.ReadKey();
}
//查询方法和查询语句综合使用
static void test08(string[] args)
{
List<Students> students = new List<Students>
{
new Students(){ StudentName="张浩明",Gender="男",Birthday=DateTime.Parse("1990-09-10")},
new Students(){ StudentName="李晓燕",Gender="女",Birthday=DateTime.Parse("1992-03-12")}//,
// new Students(){ StudentName="郝云霄",Gender="女",Birthday=DateTime.Parse("1991-09-15") }
};
//获取集合中“第一个”对象
Students objStudent = (from s in students select s).FirstOrDefault();
//输出第一个对象张浩明
Console.WriteLine(objStudent.StudentName); //删除一个对象
students.Remove(objStudent);
//获取集合中“唯一的”对象
objStudent = (from s in students select s).SingleOrDefault();
//输出唯一对象
Console.WriteLine(objStudent.StudentName);
Console.ReadLine();
} #endregion #region 使用Linq to Entities查询数据 static void test09(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
var query = from s in efdb.Students
where s.StudentId == 100002
select s;
Console.WriteLine("学号\t姓名\t年龄");
foreach (var item in query)
{
Console.WriteLine("{0}\t{1}\t{2}", item.StudentId, item.StudentName, item.Age);
}
Console.ReadKey();
} //从Linq to Objects 到 Linq to Entitis
static void test10(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
//查询姓张的男学生,并且按年龄升序排列
var stuList = from stu in efdb.Students
where stu.StudentName.StartsWith("张") && stu.Gender == "男"
&& stu.Birthday > Convert.ToDateTime("1990-01-01")
orderby stu.Age ascending
select stu;
foreach (var item in stuList)
{
Console.WriteLine(item.StudentId + "\t" + item.StudentName + "\t" + item.Age);
}
Console.ReadKey();
} static void test11(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
DateTime birthday = Convert.ToDateTime("1990-01-01");
//查询姓张的男学生,并且按年龄升序排列
var stuList = from stu in efdb.Students
where stu.StudentName.StartsWith("张") && stu.Gender == "男"
&& stu.Birthday > birthday
orderby stu.Age ascending
select stu;
foreach (var item in stuList)
{
Console.WriteLine(item.StudentId + "\t" + item.StudentName + "\t" + item.Age);
}
Console.ReadKey();
} //单表查询和数据投影
static void test12(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
var stuList = from stu in efdb.Students
where stu.StudentName.Contains("小")
orderby stu.Age descending
select new { stu.StudentId, stu.StudentName, stu.StudentIdNo, stu.Gender, stu.Age }; foreach (var item in stuList)
{
Console.WriteLine(item.StudentId + "\t" + item.StudentName + "\t" + item.Age);
}
Console.ReadKey();
} //使用Find方法实现简单查询
static void test13(string[] args)
{
EFDBEntities efdb = new EFDBEntities(); Students objStudent = efdb.Students.Find(100005); Console.WriteLine(objStudent.StudentId + "\t" +
objStudent.StudentName + "\t" + objStudent.Age);
Console.ReadKey();
} // 使用 “导航属性” 查询多表的数据
static void test14(string[] args)
{
EFDBEntities efdb = new EFDBEntities(); var stuList = from s in efdb.Students
where s.Age > 22
select new { s.StudentName, s.Age, s.StudentClass.ClassName }; foreach (var item in stuList)
{
Console.WriteLine(item.StudentName + "\t" + item.Age + "\t" + item.ClassName);
}
Console.ReadKey();
} static void test15(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
var stuList = from score in efdb.ScoreList
select new
{
score.StudentId,
score.SQLServerDB,
score.Students.StudentName,
score.Students.StudentClass.ClassName
};
foreach (var item in stuList)
{
Console.WriteLine("{0}\t{1}\t{2}\t{3}",
item.StudentId, item.StudentName, item.SQLServerDB,
item.ClassName);
}
Console.ReadKey();
} //join联接查询
static void test16(string[] args)
{
EFDBEntities efdb = new EFDBEntities(); var stuList = from score in efdb.ScoreList
join s in efdb.Students on score.StudentId equals s.StudentId
join c in efdb.StudentClass on s.ClassId equals c.ClassId
where s.Gender == "男"
select new { s.StudentId, s.StudentName, score.SQLServerDB, c.ClassName }; foreach (var item in stuList)
{
Console.WriteLine("{0}\t{1}\t{2}\t{3}",
item.StudentId,
item.StudentName,
item.SQLServerDB,
item.ClassName);
}
Console.ReadKey();
} //嵌套查询
static void test17(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
//查询班级编号为1的学员
var query = from s in efdb.Students
where s.ClassId == 1 || s.ClassId == 2
select new { s.StudentClass.ClassName, s.StudentName, s.StudentId };
//在上一个查询基础上查询年龄大于22的学员
var subQuery = from s in (query) where s.StudentId > 100002 select s;
//执行查询
var stuList = subQuery.ToList();
foreach (var item in stuList)
{
Console.WriteLine("{0}\t{1}\t{2}",
item.StudentId,
item.StudentName,
item.ClassName);
}
Console.ReadKey();
}
//子查询
static void test18(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
//使用子查询
var subQuery = from s in
(from s in efdb.Students
where s.ClassId == 1 || s.ClassId == 2
select new { s.StudentClass.ClassName, s.StudentName, s.StudentId })
where s.StudentId > 100002
select s;
//执行查询
var stuList = subQuery.ToList(); foreach (var item in stuList)
{
Console.WriteLine("{0}\t{1}\t{2}",
item.StudentId,
item.StudentName,
item.ClassName);
}
Console.ReadKey();
} //在select子句中使用子查询
static void test19(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
var query = from s in efdb.Students
select new
{
Name = s.StudentName,
Subject = from score in s.ScoreList
select new { sql = score.SQLServerDB, cs = score.CSharp }
}; //执行查询
var stuList = query.ToList();
foreach (var item in stuList)
{
Console.Write(item.Name);
foreach (var s in item.Subject)
{
Console.Write("\t{0},{1}", s.sql, s.cs);
}
Console.WriteLine();
}
Console.ReadKey();
} //聚合查询
static void test20(string[] args)
{
EFDBEntities efdb = new EFDBEntities(); //计算所有的学生总数
var query = from s in efdb.Students select s;
int stuCount = query.Count();
Console.WriteLine("学生总数:" + stuCount); //计算参考考试的学生考试总分
var scoreQuery = from s in efdb.Students
where s.ScoreList.Count() > 0//参加考试的学生
select new
{
Name = s.StudentName,
Total = (from score in s.ScoreList
select (score.SQLServerDB + score.CSharp)).Sum()
}; foreach (var item in scoreQuery)
{
Console.WriteLine("{0}\t{1}", item.Name, item.Total);
}
Console.ReadKey();
}
#endregion #region 处理关联数据 //添加对象的同时关联实体操作
static void test20(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
Students stu = new Students()
{
StudentAddress = "北京海淀区",
StudentName = "王慧慧",
StudentIdNo = 130223198910121213,
Gender = "男",
Birthday = Convert.ToDateTime("1990-10-12"),
Age = 25,
PhoneNumber = "010-88996655",
ClassId = (from c in efdb.StudentClass where c.ClassName.Equals("软件1班") select c.ClassId).SingleOrDefault(),
};
efdb.Students.Add(stu);
Console.WriteLine(efdb.SaveChanges());
Console.ReadKey();
} //通过嵌套查询获取外键对象的值
static void test21(string[] args)
{
EFDBEntities efdb = new EFDBEntities(); Students stu = new Students()
{
StudentAddress = "北京海淀区",
StudentName = "李慧慧",
StudentIdNo = 130223198910131213,
Gender = "女",
Birthday = Convert.ToDateTime("1990-10-13"),
Age = 26,
PhoneNumber = "010-88996699"
}; //查询班级实体,然后使用导航数据添加数据
(from c in efdb.StudentClass where c.ClassName.Equals("软件2班") select c).SingleOrDefault().Students.Add(stu); efdb.Students.Add(stu);
Console.WriteLine(efdb.SaveChanges());
Console.ReadKey();
} //级联删除
static void test22(string[] args)
{
EFDBEntities efdb = new EFDBEntities(); //找到软件2班
var stuClass = (from c in efdb.StudentClass where c.ClassId == 2 select c).SingleOrDefault(); //删除软件2班的学生
for (int i = 0; i < stuClass.Students.Count; i++)
{
efdb.Students.Remove(stuClass.Students.FirstOrDefault());
}
//删除软件2班
efdb.StudentClass.Remove(stuClass);
Console.WriteLine(efdb.SaveChanges());
Console.ReadKey(); //efdb.Set<Students>().Attach(stu);
// efdb.Entry<Students>(stu).State = EntityState.Deleted; } #endregion #region 状态跟踪与管理 static void test23(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
var stuList = from stu in efdb.Students
where stu.StudentId > 100002
select stu;
string sql = stuList.ToString();
Console.WriteLine(sql);
Console.ReadLine();
}
static void test24(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
int stuId = 100002;
var stuList = from stu in efdb.Students
where stu.StudentId > stuId
select stu;
string sql = stuList.ToString();
Console.WriteLine(sql);
Console.ReadLine();
}
//状态跟踪
static void test25(string[] args)
{
EFDBEntities efdb = new EFDBEntities(); StudentClass stuClass = new StudentClass() { ClassId = 10, ClassName = "软件10班" };
Console.WriteLine(efdb.Entry(stuClass).State.ToString()); //输出当前对象的状态 efdb.StudentClass.Add(stuClass);
Console.WriteLine(efdb.Entry(stuClass).State.ToString()); efdb.SaveChanges();
Console.WriteLine(efdb.Entry(stuClass).State.ToString()); Console.ReadLine();
} //无状态跟踪
static void test26(string[] args)
{
EFDBEntities efdb = new EFDBEntities(); //状态跟踪查询
var stu1 = (from s in efdb.Students select s).FirstOrDefault();
Console.WriteLine(efdb.Entry(stu1).State.ToString()); //无状态跟踪查询
var stu2 = efdb.Students.AsNoTracking().Select(s => s).FirstOrDefault();
Console.WriteLine(efdb.Entry(stu2).State.ToString());
Console.ReadLine();
} //关闭状态管理
static void test27(string[] args)
{
EFDBEntities efdb = new EFDBEntities(); efdb.Configuration.AutoDetectChangesEnabled = false;//禁用 for (int i = 20; i < 25; i++)
{
StudentClass stuClass = new StudentClass() { ClassId = i, ClassName = string.Format("软件{0}班", i) };
efdb.StudentClass.Add(stuClass);
}
Console.WriteLine(efdb.SaveChanges()); Console.ReadLine();
} #endregion #region EF优化后: 基于Linq查询的CRUD //添加
static void test28(string[] args)
{
Students stu = new Students()
{
StudentAddress = "天津南开区狮子林大街28号",
StudentName = "李超阳",
StudentIdNo = 130223198910111213,
ClassId = 2,
Gender = "男",
Birthday = Convert.ToDateTime("1990-10-11"),
Age = 24,
PhoneNumber = "022-55662232"
}; using (EFDBEntities efdb = new EFDBEntities())
{
efdb.Entry<Students>(stu).State = EntityState.Added;//显示告诉变化
// efdb.Students.Add(stu);
Console.WriteLine(efdb.SaveChanges());
} Console.ReadLine();
} static void test29(string[] args)
{
Students stu = new Students()
{
StudentAddress = "天津南开区狮子林大街29号",
StudentName = "王超阳",
StudentIdNo = 130223198911111219,
ClassId = 1,
Gender = "男",
Birthday = Convert.ToDateTime("1990-11-19"),
Age = 28,
PhoneNumber = "022-5566888888"
};
Console.ReadLine();
} //修改
static void test30(string[] args)
{
Students stu = new Students()
{
StudentAddress = "2222",
StudentName = "2222",
StudentIdNo = 130223198910111222,
ClassId = 2,
Gender = "男",
Birthday = Convert.ToDateTime("1990-10-11"),
Age = 24,
PhoneNumber = "88888888",
StudentId = 100007//注意:这个应该改成你数据库的具体值
};
using (EFDBEntities efdb = new EFDBEntities())
{
efdb.Entry<Students>(stu).State = EntityState.Modified;//显示告诉变化
Console.WriteLine(efdb.SaveChanges());
} Console.ReadLine();
} //删除
static void test30(string[] args)
{
Students stu = new Students()
{
StudentId = 100019 //根据主键删除
};
using (EFDBEntities efdb = new EFDBEntities())
{
efdb.Set<Students>().Attach(stu);//将给定实体添加到上下文
efdb.Entry<Students>(stu).State = EntityState.Deleted;
Console.WriteLine(efdb.SaveChanges());
};
Console.ReadLine();
} static void test31(string[] args)
{
Students stu = new Students()
{
StudentId = 100012 //根据主键删除
};
using (EFDBEntities efdb = new EFDBEntities())
{
efdb.Set<Students>().Attach(stu);
efdb.Students.Remove(stu);
efdb.SaveChanges();
};
Console.ReadLine();
} //查询
static void test32(string[] args)
{
EFDBEntities efdb = new EFDBEntities();
var stuList = from stu in efdb.Students
where stu.StudentId > 100002
select stu; foreach (var item in stuList)
{
Console.WriteLine(item.StudentId + "\t" + item.StudentName);
}
Console.ReadLine();
} //使用缓存
static void test33(string[] args)
{
using (EFDBEntities efdb = new EFDBEntities())
{
var stuList = from stu in efdb.Students select stu;
foreach (var item in stuList)
{
Console.WriteLine(item.StudentId + "\t" + item.StudentName);
} //查询学生总数
// Console.WriteLine("学生总数:{0}", efdb.Students.Count()); //使用缓存查询学生总数
Console.WriteLine("学生总数:{0}", efdb.Students.Local.Count()); Console.ReadLine();
}
}
#endregion #region 从实体框架回归到SQL
static void test34(string[] args)
{
string sql1 = "update Students set StudentName='张新宇' where StudentId=100002";
string sql2 = "update Students set StudentName=@StudentName where StudentId=@StudentId";
SqlParameter[] param = new SqlParameter[]
{
new SqlParameter("@StudentName","刘莉"), new SqlParameter("@StudentId",100004)
}; using (EFDBEntities efdb = new EFDBEntities())
{
int result1 = efdb.Database.ExecuteSqlCommand(sql1);
int result2 = efdb.Database.ExecuteSqlCommand(sql2, param);
Console.WriteLine(result1 + " " + result2);
} Console.ReadLine();
} static void test35(string[] args)
{
string sql1 = "select count(*) from Students";
string sql2 = "select * from Students where Gender=@Gender";
SqlParameter[] param = new SqlParameter[]
{
new SqlParameter("@Gender","男")
}; using (EFDBEntities efdb = new EFDBEntities())
{ int stuCount = efdb.Database.SqlQuery<int>(sql1).ToList()[0];
var stuList = efdb.Database.SqlQuery<Students>(sql2, param); Console.WriteLine("学生总数:" + stuCount);
foreach (var stu in stuList)
{
Console.WriteLine("{0}\t{1}\t{2}", stu.StudentId, stu.StudentName, stu.Age);
}
};
Console.ReadLine();
}
//调用存储过程
static void test36(string[] args)
{
SqlParameter[] param1 = new SqlParameter[]
{
new SqlParameter("@StudentName","王大彪"), new SqlParameter("@StudentId",100004)
};
SqlParameter[] param2 = new SqlParameter[]
{
new SqlParameter("@ClassId",1)
};
using (EFDBEntities efdb = new EFDBEntities())
{
int result = efdb.Database.ExecuteSqlCommand("execute usp_updateStu @StudentName,@StudentId", param1);
var stuList = efdb.Database.SqlQuery<Students>("execute usp_selectStu @ClassId", param2);
Console.WriteLine(result);
foreach (var stu in stuList)
{
Console.WriteLine("{0}\t{1}\t{2}", stu.StudentId, stu.StudentName, stu.Age);
}
}; Console.ReadLine();
}
#endregion
}
}

EntityFramework介绍的更多相关文章

  1. ORM框架之EntityFramework介绍

    ORM框架之EntityFramework介绍 1. 简介 大家好!我是高堂. 作为一位伪前端程序猿,我给大家介绍一下微软的自家的 ORM框架. ADO.NET Entity Framework 以下 ...

  2. C#+JQuery+.Ashx+百度Echarts实现全国省市地图和饼状图动态数据图形报表的统计

    在目前的一个项目中,需要用到报表表现数据,这些数据有多个维度,需要同时表现出来,同时可能会有大量数据呈现的需求,经过几轮挑选,最终选择了百度的echarts作为报表基础类库.echarts功能强大,界 ...

  3. Entity Framework 新手入门友好实例

    起因 因为实习的原因,程序之中用到了较多的数据库操作逻辑.如果每一处数据库操作都手写的话,工作量较大且后期不易于维护,所以希望能通过 ORM 框架来解决这两个问题. 在昨天之前,对于 ORM 这个词汇 ...

  4. [01]从零开始学 ASP.NET Core 与 EntityFramework Core 课程介绍

    从零开始学 ASP.NET Core 与 EntityFramework Core 课程介绍 本文作者:梁桐铭- 微软最有价值专家(Microsoft MVP) 文章会随着版本进行更新,关注我获取最新 ...

  5. EntityFramework ,ef 介绍

    EntityFramework之领域驱动设计实践 分层架构 在引入实例以前,我们有必要回顾,并进一步了解分层架构.“层”是一种体系结构模式[POSA1],也是被广大软件从业人员用得最为广泛而且最为灵活 ...

  6. EntityFramework数据持久化 Linq介绍

    一.LINQ概述与查询语法 二.LINQ方法语法基础(重点) 三.LINQ聚合操作与元素操作(重点) 四.数据类型转换(重点) 一.LINQ概述与查询语法 1.LINQ(Language Integr ...

  7. 采用EntityFramework.Extended 对EF进行扩展(Entity Framework 延伸系列2)

    前言 Entity Framework 延伸系列目录 今天我们来讲讲EntityFramework.Extended 首先科普一下这个EntityFramework.Extended是什么,如下: 这 ...

  8. 介绍,介绍我的底层支持库 Net.Sz.CFramework

    Net.Sz.CFramework  是我自己的底层库,是经过验证的底层库. 包含: socket tcp协议,socket http协议线程池,线程模型,任务模型,定时器模型,日志模块脚本模块一些辅 ...

  9. 监视EntityFramework中的sql流转你需要知道的三种方式Log,SqlServerProfile, EFProfile

    大家在学习entityframework的时候,都知道那linq写的叫一个爽,再也不用区分不同RDMS的sql版本差异了,但是呢,高效率带来了差灵活性,我们 无法控制sql的生成策略,所以必须不要让自 ...

随机推荐

  1. Python入门系列(二)语法风格

    python缩进 Python使用缩进来表示代码块,例如 if 5 > 2: print("Five is greater than two!") 如果跳过缩进,Python ...

  2. 简单创建一个SpringCloud2021.0.3项目(四)

    目录 1. 项目说明 1. 版本 2. 用到组件 3. 功能 2. 上三篇教程 3. 日志处理 1. 创建日志公共模块 2. Eureka引入日志模块 4. 到此的功能代码 5. 注册中心换成naco ...

  3. Qt 场景创建

    1 创建  Q t Widget Application 2 创建窗口 3 创建后的目录  创建完成后运行一下 4 导入资源  将res文件拷贝到 项目工程目录下 添加资源 选择一模版.Qt-Reso ...

  4. .Net+Vue3实现数据简易导入功能

    在开发的过程中,上传文件或者导入数据是一件很常见的事情,导入数据可以有两种方式: 前端上传文件到后台,后台读取文件内容,进行验证再进行存储 前端读取数据,进行数据验证,然后发送数据到后台进行存储 这两 ...

  5. 邮箱的代理发送Send as权限不生效

     邮箱的代理发送Sendas权限不生效 最近,有需求为用户添加其它邮箱的代理发送Sendas权限.在Exchange的管理单元里添加完毕后,发现没有效果,客户端提示你没有权限以用户的名义发送邮件 ...

  6. Git Rebase-提交整洁之道

    git rebase git rebase是一个非常有用的命令,但知道和用的人非常少,今天介绍一下其作用 git rebase -i 作用:常用来合并多个相同目的的提交. 交互式有下面几个命令,常用命 ...

  7. vue this.$router.push query传递对象方法

    this.$router.push({ path: '/home', query: { params: JSON.stringify({ name: 'lokka', age: 18 }) } }); ...

  8. 6_SSM

    一. ssm整合 1.1 项目创建 1.1.1 创建Maven项目 创建一个普通的Maven-web项目,名称为ssm 记得勾选上Create from archetype然后选择后缀为maven-a ...

  9. 前端三件套 HTML+CSS+JS基础知识内容笔记

    HTML基础 目录 HTML基础 HTML5标签 doctype 标签 html标签 head标签 meta标签 title标签 body标签 文本和超链接标签 标题标签 段落标签 换行标签 水平标签 ...

  10. Java实现6种常见排序

    1.冒泡排序(Bubble Sort) 第0轮 3 1 4 1 5 9 2 6 5 3 5 8 9 第1轮 1 3 1 4 5 2 6 5 3 5 8 9 9 第2轮 1 1 3 4 2 5 5 3 ...