commit ee0e9b9aac91217855ff3e14c30560cba4b54b26 Author: editor <@51Aspx.com> Date: Tue Jun 25 16:57:14 2024 +0800 初始化 diff --git a/51Aspx源码必读.txt b/51Aspx源码必读.txt new file mode 100644 index 0000000..1f87a1f --- /dev/null +++ b/51Aspx源码必读.txt @@ -0,0 +1,40 @@ +ASP.NET简单ORM示例源码 + +一、源码描述 +环境:VS2022 sql2019 + +二、功能介绍 +通过一个人员管理小程序详细介绍了Asp.net中ORM(Object Relational Mapping)的应用,详细说明请参照代码佩文 +采用了DAL、BLL、Model多层模式 +该代码实现了数据的添加、修改、删除和查询 +Employee.aspx为主文件 +ORMappings/Employee.xml,ORMappings/Person.xml 为映射配置文件 +DB_51Aspx下为数据库文件附加即可 + +三、注意事项 +ctrl+F5运行即可。 + + + + + +作者: ColdDog + +如需获得该源码的视频、更新等更多资料请访问: https://www.51aspx.com/Code/ORMDemo +------------------------------------------------------------------------------------------------ + + 源码服务专家 + 官网: https://www.51aspx.com + 讨论圈: https://club.51aspx.com/ + +平台声明: + +1.51Aspx平台上提供下载的资源为免费、共享、商业三类源码,其中免费和共享源码仅供个人学习和研究使用,商业源码请在相应的授权许可条件下使用; +2.51Aspx平台对提供下载的软件及其它资源不拥有任何权利,其版权归属源码合法拥有者所有; +3.著作权人发现本网站载有侵害其合法权益的内容或作品,请与我们联系( 登录官网与客服反馈或发送邮件到support@51Aspx.com ); +4.51Aspx平台不保证提供的下载资源的准确性、安全性和完整性; + +友情提示: + 一般数据库文件默认在 DB_51Aspx 文件夹下 + 默认账号密码一般均为51Aspx + 关于源码使用常见问题及解决方案,请参阅: https://www.51aspx.com/Help diff --git a/BLL/BLL.csproj b/BLL/BLL.csproj new file mode 100644 index 0000000..fdf9be3 --- /dev/null +++ b/BLL/BLL.csproj @@ -0,0 +1,15 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {6B617321-254B-4789-B487-A352852B8CBA} + Library + Properties + BLL + BLL + + + + diff --git a/BLL/Department.cs b/BLL/Department.cs new file mode 100644 index 0000000..00293c3 --- /dev/null +++ b/BLL/Department.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using DAL; +using Model; + +namespace BLL +{ + public class Department : ObjectStore + { + public static Department TheInstance = new Department(); + + public Department() + { } + diff --git a/BLL/Employee.cs b/BLL/Employee.cs new file mode 100644 index 0000000..915d9ba --- /dev/null +++ b/BLL/Employee.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using DAL; +using Model; + +namespace BLL +{ + public class Employee : ObjectStore + { + public static Employee TheInstance = new Employee(); + + public Employee() + { } + diff --git a/BLL/ObjectStore.cs b/BLL/ObjectStore.cs new file mode 100644 index 0000000..ba99cbf --- /dev/null +++ b/BLL/ObjectStore.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Data; +using System.Data.Common; +using System.Data.SqlClient; +using DAL; +using Model; + +namespace BLL +{ + public class ObjectStore + { + //public static ObjectStore TheInstance = new ObjectStore(); + diff --git a/BLL/Person.cs b/BLL/Person.cs new file mode 100644 index 0000000..fc77c4f --- /dev/null +++ b/BLL/Person.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using DAL; +using Model; + +namespace BLL +{ + public class Person : ObjectStore + { + public static Person TheInstance = new Person(); + + public Person() + { } + diff --git a/BLL/Properties/AssemblyInfo.cs b/BLL/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..010840b --- /dev/null +++ b/BLL/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过下列属性集 +// 控制。更改这些属性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("BLL")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("SeaSky")] +[assembly: AssemblyProduct("BLL")] +[assembly: AssemblyCopyright("版权所有 (C) SeaSky 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/BLL/obj/BLL.csproj.FileList.txt b/BLL/obj/BLL.csproj.FileList.txt new file mode 100644 index 0000000..5603a37 --- /dev/null +++ b/BLL/obj/BLL.csproj.FileList.txt @@ -0,0 +1,9 @@ +bin\Debug\BLL.dll +bin\Debug\BLL.pdb +bin\Debug\Model.dll +bin\Debug\Model.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\BLL.dll +obj\Debug\BLL.pdb +bin\Debug\DAL.dll +bin\Debug\DAL.pdb diff --git a/BLL/obj/Debug/.NETFramework,Version=v4.0.AssemblyAttributes.cs b/BLL/obj/Debug/.NETFramework,Version=v4.0.AssemblyAttributes.cs new file mode 100644 index 0000000..5d01041 --- /dev/null +++ b/BLL/obj/Debug/.NETFramework,Version=v4.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")] diff --git a/BLL/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs b/BLL/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs new file mode 100644 index 0000000..15efebf --- /dev/null +++ b/BLL/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] diff --git a/BLL/obj/Debug/BLL.csproj.FileListAbsolute.txt b/BLL/obj/Debug/BLL.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..1bc9017 --- /dev/null +++ b/BLL/obj/Debug/BLL.csproj.FileListAbsolute.txt @@ -0,0 +1,11 @@ +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\BLL\bin\Debug\BLL.dll +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\BLL\bin\Debug\BLL.pdb +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\BLL\bin\Debug\DAL.dll +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\BLL\bin\Debug\Model.dll +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\BLL\bin\Debug\DAL.pdb +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\BLL\bin\Debug\Model.pdb +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\BLL\obj\Debug\BLL.csproj.AssemblyReference.cache +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\BLL\obj\Debug\BLL.csproj.CoreCompileInputs.cache +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\BLL\obj\Debug\BLL.csproj.Up2Date +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\BLL\obj\Debug\BLL.dll +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\BLL\obj\Debug\BLL.pdb diff --git a/Backup/BLL/BLL.csproj b/Backup/BLL/BLL.csproj new file mode 100644 index 0000000..9aa3f06 --- /dev/null +++ b/Backup/BLL/BLL.csproj @@ -0,0 +1,15 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {6B617321-254B-4789-B487-A352852B8CBA} + Library + Properties + BLL + BLL + + + true + full diff --git a/Backup/BLL/Department.cs b/Backup/BLL/Department.cs new file mode 100644 index 0000000..00293c3 --- /dev/null +++ b/Backup/BLL/Department.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using DAL; +using Model; + +namespace BLL +{ + public class Department : ObjectStore + { + public static Department TheInstance = new Department(); + + public Department() + { } + diff --git a/Backup/BLL/Employee.cs b/Backup/BLL/Employee.cs new file mode 100644 index 0000000..915d9ba --- /dev/null +++ b/Backup/BLL/Employee.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using DAL; +using Model; + +namespace BLL +{ + public class Employee : ObjectStore + { + public static Employee TheInstance = new Employee(); + + public Employee() + { } + diff --git a/Backup/BLL/ObjectStore.cs b/Backup/BLL/ObjectStore.cs new file mode 100644 index 0000000..ba99cbf --- /dev/null +++ b/Backup/BLL/ObjectStore.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Data; +using System.Data.Common; +using System.Data.SqlClient; +using DAL; +using Model; + +namespace BLL +{ + public class ObjectStore + { + //public static ObjectStore TheInstance = new ObjectStore(); + diff --git a/Backup/BLL/Person.cs b/Backup/BLL/Person.cs new file mode 100644 index 0000000..fc77c4f --- /dev/null +++ b/Backup/BLL/Person.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using DAL; +using Model; + +namespace BLL +{ + public class Person : ObjectStore + { + public static Person TheInstance = new Person(); + + public Person() + { } + diff --git a/Backup/BLL/Properties/AssemblyInfo.cs b/Backup/BLL/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..010840b --- /dev/null +++ b/Backup/BLL/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过下列属性集 +// 控制。更改这些属性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("BLL")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("SeaSky")] +[assembly: AssemblyProduct("BLL")] +[assembly: AssemblyCopyright("版权所有 (C) SeaSky 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/Backup/DAL/DAL.csproj b/Backup/DAL/DAL.csproj new file mode 100644 index 0000000..48d88fa --- /dev/null +++ b/Backup/DAL/DAL.csproj @@ -0,0 +1,15 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {B3F86D52-6F47-4F6A-ABFD-15C2004785F6} + Library + Properties + DAL + DAL + + + true + full diff --git a/Backup/DAL/DbCommandStore.cs b/Backup/DAL/DbCommandStore.cs new file mode 100644 index 0000000..9b416e0 --- /dev/null +++ b/Backup/DAL/DbCommandStore.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Data.Common; +using System.Data.SqlClient; +using System.Data.OracleClient; +using System.Configuration; +using System.Collections.Generic; +using System.Text; + +namespace DAL +{ + public class DbCommandStore + { + public static DbCommandStore TheInstance = new DbCommandStore(); + private Dictionary _commandCache = new Dictionary(); diff --git a/Backup/DAL/DbConnectionStore.cs b/Backup/DAL/DbConnectionStore.cs new file mode 100644 index 0000000..40882e7 --- /dev/null +++ b/Backup/DAL/DbConnectionStore.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Data.Common; +using System.Data.SqlClient; +using System.Data.OracleClient; +using System.Configuration; +using System.Web.Configuration; + +namespace DAL +{ + public class DbConnectionStore + { + public static DbConnectionStore TheInstance = new DbConnectionStore(); + public static readonly string DBNAME = System.Web.Configuration.WebConfigurationManager.AppSettings["DBName"]; + diff --git a/Backup/DAL/MappingStore.cs b/Backup/DAL/MappingStore.cs new file mode 100644 index 0000000..2a35245 --- /dev/null +++ b/Backup/DAL/MappingStore.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Runtime.Serialization; +using System.Xml; +using System.IO; + +//��Դ��������www.51aspx.com(���������������) + +namespace DAL +{ + public class MappingStore + { + private Dictionary __mappings = new Dictionary(); + diff --git a/Backup/DAL/MyBuildProvider.cs b/Backup/DAL/MyBuildProvider.cs new file mode 100644 index 0000000..2716ce2 --- /dev/null +++ b/Backup/DAL/MyBuildProvider.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Web.Compilation; +using System.Xml; +using System.Diagnostics; + +using System.CodeDom; +using Microsoft.CSharp; + +namespace DAL +{ + public class MyBuildProvider : BuildProvider + { + public override void GenerateCode(AssemblyBuilder ab) diff --git a/Backup/DAL/ObjectStore.cs b/Backup/DAL/ObjectStore.cs new file mode 100644 index 0000000..c1e2ba8 --- /dev/null +++ b/Backup/DAL/ObjectStore.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Data.Common; +using System.Configuration; +using System.Data.SqlClient; +using System.Reflection; + +namespace DAL +{ + public class ObjectStore + { + #region Query + //public static T Select(params object[] keys) diff --git a/Backup/DAL/Properties/AssemblyInfo.cs b/Backup/DAL/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dcbe950 --- /dev/null +++ b/Backup/DAL/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CodeGenerator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("CT")] +[assembly: AssemblyProduct("CodeGenerator")] +[assembly: AssemblyCopyright("Copyright � CT 2005")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/Backup/DAL/Query.cs b/Backup/DAL/Query.cs new file mode 100644 index 0000000..2b47e84 --- /dev/null +++ b/Backup/DAL/Query.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Data.Common; +using System.Configuration; +using System.Data.SqlClient; +using System.Reflection; + +namespace DAL +{ + public class Query where T : new() + { + private Type _type; + private T _obj; diff --git a/Backup/Model/DepartmentInfo.cs b/Backup/Model/DepartmentInfo.cs new file mode 100644 index 0000000..ad5d8a4 --- /dev/null +++ b/Backup/Model/DepartmentInfo.cs @@ -0,0 +1,15 @@ +using System; + +namespace Model +{ + /// + /// + /// + public class DepartmentInfo + { + private int _departmentID; + private string _departmentName; + + /// + /// Ĭ�Ϲ��캯�� + /// diff --git a/Backup/Model/EmployeeInfo.cs b/Backup/Model/EmployeeInfo.cs new file mode 100644 index 0000000..4329e51 --- /dev/null +++ b/Backup/Model/EmployeeInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Configuration; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; + +namespace Model +{ + public class EmployeeInfo : PersonInfo + { + protected int _employeeId; diff --git a/Backup/Model/Model.csproj b/Backup/Model/Model.csproj new file mode 100644 index 0000000..f349a5f --- /dev/null +++ b/Backup/Model/Model.csproj @@ -0,0 +1,15 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {71F8A2BA-BACA-495E-8EDF-E8A452C7F049} + Library + Properties + Model + Model + + + true + full diff --git a/Backup/Model/PersonInfo.cs b/Backup/Model/PersonInfo.cs new file mode 100644 index 0000000..9039742 --- /dev/null +++ b/Backup/Model/PersonInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Configuration; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; + +namespace Model +{ + public class PersonInfo + { + protected string _firstName; diff --git a/Backup/Model/Properties/AssemblyInfo.cs b/Backup/Model/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ef7d6b3 --- /dev/null +++ b/Backup/Model/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过下列属性集 +// 控制。更改这些属性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Model")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("SeaSky")] +[assembly: AssemblyProduct("Model")] +[assembly: AssemblyCopyright("版权所有 (C) SeaSky 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/DAL/.vs/DAL.csproj.dtbcache.json b/DAL/.vs/DAL.csproj.dtbcache.json new file mode 100644 index 0000000..f951be3 --- /dev/null +++ b/DAL/.vs/DAL.csproj.dtbcache.json @@ -0,0 +1 @@ +{"RootPath":"C:\\Users\\coder\\Desktop\\2024Code\\6\\20240625\\update\\ORMDemo\\DAL","ProjectFileName":"DAL.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"DbCommandStore.cs"},{"SourceFile":"DbConnectionStore.cs"},{"SourceFile":"MappingStore.cs"},{"SourceFile":"MyBuildProvider.cs"},{"SourceFile":"ObjectStore.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Query.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.0.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.configuration\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.configuration.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Core\\v4.0_4.0.0.0__b77a5c561934e089\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_64\\System.Data\\v4.0_4.0.0.0__b77a5c561934e089\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_64\\System.Data.OracleClient\\v4.0_4.0.0.0__b77a5c561934e089\\System.Data.OracleClient.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System\\v4.0_4.0.0.0__b77a5c561934e089\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_64\\System.Web\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Web.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Xml\\v4.0_4.0.0.0__b77a5c561934e089\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Users\\coder\\Desktop\\2024Code\\6\\20240625\\update\\ORMDemo\\DAL\\bin\\Debug\\DAL.dll","OutputItemRelativePath":"DAL.dll"},{"OutputItemFullPath":"C:\\Users\\coder\\Desktop\\2024Code\\6\\20240625\\update\\ORMDemo\\DAL\\bin\\Debug\\DAL.pdb","OutputItemRelativePath":"DAL.pdb"}],"CopyToOutputEntries":[]} diff --git a/DAL/DAL.csproj b/DAL/DAL.csproj new file mode 100644 index 0000000..4452efc --- /dev/null +++ b/DAL/DAL.csproj @@ -0,0 +1,15 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {B3F86D52-6F47-4F6A-ABFD-15C2004785F6} + Library + Properties + DAL + DAL + + + + diff --git a/DAL/DbCommandStore.cs b/DAL/DbCommandStore.cs new file mode 100644 index 0000000..9b416e0 --- /dev/null +++ b/DAL/DbCommandStore.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Data.Common; +using System.Data.SqlClient; +using System.Data.OracleClient; +using System.Configuration; +using System.Collections.Generic; +using System.Text; + +namespace DAL +{ + public class DbCommandStore + { + public static DbCommandStore TheInstance = new DbCommandStore(); + private Dictionary _commandCache = new Dictionary(); diff --git a/DAL/DbConnectionStore.cs b/DAL/DbConnectionStore.cs new file mode 100644 index 0000000..40882e7 --- /dev/null +++ b/DAL/DbConnectionStore.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Data.Common; +using System.Data.SqlClient; +using System.Data.OracleClient; +using System.Configuration; +using System.Web.Configuration; + +namespace DAL +{ + public class DbConnectionStore + { + public static DbConnectionStore TheInstance = new DbConnectionStore(); + public static readonly string DBNAME = System.Web.Configuration.WebConfigurationManager.AppSettings["DBName"]; + diff --git a/DAL/MappingStore.cs b/DAL/MappingStore.cs new file mode 100644 index 0000000..2a35245 --- /dev/null +++ b/DAL/MappingStore.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Runtime.Serialization; +using System.Xml; +using System.IO; + +//��Դ��������www.51aspx.com(���������������) + +namespace DAL +{ + public class MappingStore + { + private Dictionary __mappings = new Dictionary(); + diff --git a/DAL/MyBuildProvider.cs b/DAL/MyBuildProvider.cs new file mode 100644 index 0000000..2716ce2 --- /dev/null +++ b/DAL/MyBuildProvider.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Web.Compilation; +using System.Xml; +using System.Diagnostics; + +using System.CodeDom; +using Microsoft.CSharp; + +namespace DAL +{ + public class MyBuildProvider : BuildProvider + { + public override void GenerateCode(AssemblyBuilder ab) diff --git a/DAL/ObjectStore.cs b/DAL/ObjectStore.cs new file mode 100644 index 0000000..c1e2ba8 --- /dev/null +++ b/DAL/ObjectStore.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Data.Common; +using System.Configuration; +using System.Data.SqlClient; +using System.Reflection; + +namespace DAL +{ + public class ObjectStore + { + #region Query + //public static T Select(params object[] keys) diff --git a/DAL/Properties/AssemblyInfo.cs b/DAL/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dcbe950 --- /dev/null +++ b/DAL/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CodeGenerator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("CT")] +[assembly: AssemblyProduct("CodeGenerator")] +[assembly: AssemblyCopyright("Copyright � CT 2005")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/DAL/Query.cs b/DAL/Query.cs new file mode 100644 index 0000000..2b47e84 --- /dev/null +++ b/DAL/Query.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Data.Common; +using System.Configuration; +using System.Data.SqlClient; +using System.Reflection; + +namespace DAL +{ + public class Query where T : new() + { + private Type _type; + private T _obj; diff --git a/DAL/obj/CodeGenerator.csproj.FileList.txt b/DAL/obj/CodeGenerator.csproj.FileList.txt new file mode 100644 index 0000000..39c6ccd --- /dev/null +++ b/DAL/obj/CodeGenerator.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\CodeGenerator.dll +bin\Debug\CodeGenerator.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\CodeGenerator.dll +obj\Debug\CodeGenerator.pdb diff --git a/DAL/obj/DAL.csproj.FileList.txt b/DAL/obj/DAL.csproj.FileList.txt new file mode 100644 index 0000000..bdfd8c9 --- /dev/null +++ b/DAL/obj/DAL.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\DAL.dll +bin\Debug\DAL.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\DAL.dll +obj\Debug\DAL.pdb diff --git a/DAL/obj/Debug/.NETFramework,Version=v4.0.AssemblyAttributes.cs b/DAL/obj/Debug/.NETFramework,Version=v4.0.AssemblyAttributes.cs new file mode 100644 index 0000000..5d01041 --- /dev/null +++ b/DAL/obj/Debug/.NETFramework,Version=v4.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")] diff --git a/DAL/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs b/DAL/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs new file mode 100644 index 0000000..15efebf --- /dev/null +++ b/DAL/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] diff --git a/DAL/obj/Debug/DAL.csproj.FileListAbsolute.txt b/DAL/obj/Debug/DAL.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..ef70f50 --- /dev/null +++ b/DAL/obj/Debug/DAL.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\DAL\bin\Debug\DAL.dll +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\DAL\bin\Debug\DAL.pdb +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\DAL\obj\Debug\DAL.csproj.AssemblyReference.cache +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\DAL\obj\Debug\DAL.csproj.CoreCompileInputs.cache +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\DAL\obj\Debug\DAL.dll +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\DAL\obj\Debug\DAL.pdb diff --git a/Model/DepartmentInfo.cs b/Model/DepartmentInfo.cs new file mode 100644 index 0000000..ad5d8a4 --- /dev/null +++ b/Model/DepartmentInfo.cs @@ -0,0 +1,15 @@ +using System; + +namespace Model +{ + /// + /// + /// + public class DepartmentInfo + { + private int _departmentID; + private string _departmentName; + + /// + /// Ĭ�Ϲ��캯�� + /// diff --git a/Model/EmployeeInfo.cs b/Model/EmployeeInfo.cs new file mode 100644 index 0000000..4329e51 --- /dev/null +++ b/Model/EmployeeInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Configuration; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; + +namespace Model +{ + public class EmployeeInfo : PersonInfo + { + protected int _employeeId; diff --git a/Model/Model.csproj b/Model/Model.csproj new file mode 100644 index 0000000..f4dc06e --- /dev/null +++ b/Model/Model.csproj @@ -0,0 +1,15 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {71F8A2BA-BACA-495E-8EDF-E8A452C7F049} + Library + Properties + Model + Model + + + + diff --git a/Model/PersonInfo.cs b/Model/PersonInfo.cs new file mode 100644 index 0000000..9039742 --- /dev/null +++ b/Model/PersonInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Configuration; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; + +namespace Model +{ + public class PersonInfo + { + protected string _firstName; diff --git a/Model/Properties/AssemblyInfo.cs b/Model/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ef7d6b3 --- /dev/null +++ b/Model/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过下列属性集 +// 控制。更改这些属性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Model")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("SeaSky")] +[assembly: AssemblyProduct("Model")] +[assembly: AssemblyCopyright("版权所有 (C) SeaSky 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/Model/obj/Debug/.NETFramework,Version=v4.0.AssemblyAttributes.cs b/Model/obj/Debug/.NETFramework,Version=v4.0.AssemblyAttributes.cs new file mode 100644 index 0000000..5d01041 --- /dev/null +++ b/Model/obj/Debug/.NETFramework,Version=v4.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")] diff --git a/Model/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs b/Model/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs new file mode 100644 index 0000000..15efebf --- /dev/null +++ b/Model/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] diff --git a/Model/obj/Debug/Model.csproj.FileListAbsolute.txt b/Model/obj/Debug/Model.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..17e4630 --- /dev/null +++ b/Model/obj/Debug/Model.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\Model\bin\Debug\Model.dll +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\Model\bin\Debug\Model.pdb +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\Model\obj\Debug\Model.csproj.AssemblyReference.cache +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\Model\obj\Debug\Model.csproj.CoreCompileInputs.cache +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\Model\obj\Debug\Model.dll +C:\Users\coder\Desktop\2024Code\6\20240625\update\ORMDemo\Model\obj\Debug\Model.pdb diff --git a/Model/obj/Model.csproj.FileList.txt b/Model/obj/Model.csproj.FileList.txt new file mode 100644 index 0000000..c48ae55 --- /dev/null +++ b/Model/obj/Model.csproj.FileList.txt @@ -0,0 +1,5 @@ +obj\Debug\ResolveAssemblyReference.cache +bin\Debug\Model.dll +bin\Debug\Model.pdb +obj\Debug\Model.dll +obj\Debug\Model.pdb diff --git a/Web/51aspx源码必读.txt b/Web/51aspx源码必读.txt new file mode 100644 index 0000000..1f87a1f --- /dev/null +++ b/Web/51aspx源码必读.txt @@ -0,0 +1,40 @@ +ASP.NET简单ORM示例源码 + +一、源码描述 +环境:VS2022 sql2019 + +二、功能介绍 +通过一个人员管理小程序详细介绍了Asp.net中ORM(Object Relational Mapping)的应用,详细说明请参照代码佩文 +采用了DAL、BLL、Model多层模式 +该代码实现了数据的添加、修改、删除和查询 +Employee.aspx为主文件 +ORMappings/Employee.xml,ORMappings/Person.xml 为映射配置文件 +DB_51Aspx下为数据库文件附加即可 + +三、注意事项 +ctrl+F5运行即可。 + + + + + +作者: ColdDog + +如需获得该源码的视频、更新等更多资料请访问: https://www.51aspx.com/Code/ORMDemo +------------------------------------------------------------------------------------------------ + + 源码服务专家 + 官网: https://www.51aspx.com + 讨论圈: https://club.51aspx.com/ + +平台声明: + +1.51Aspx平台上提供下载的资源为免费、共享、商业三类源码,其中免费和共享源码仅供个人学习和研究使用,商业源码请在相应的授权许可条件下使用; +2.51Aspx平台对提供下载的软件及其它资源不拥有任何权利,其版权归属源码合法拥有者所有; +3.著作权人发现本网站载有侵害其合法权益的内容或作品,请与我们联系( 登录官网与客服反馈或发送邮件到support@51Aspx.com ); +4.51Aspx平台不保证提供的下载资源的准确性、安全性和完整性; + +友情提示: + 一般数据库文件默认在 DB_51Aspx 文件夹下 + 默认账号密码一般均为51Aspx + 关于源码使用常见问题及解决方案,请参阅: https://www.51aspx.com/Help diff --git a/Web/App_Code/DepartmentProxy.cs b/Web/App_Code/DepartmentProxy.cs new file mode 100644 index 0000000..5fb0d3c --- /dev/null +++ b/Web/App_Code/DepartmentProxy.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Configuration; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; +using System.Collections.Generic; +using Model; +using BLL; + +/// +/// DepartmentProxy 的摘要说明 diff --git a/Web/App_Code/EmployeeProxy.cs b/Web/App_Code/EmployeeProxy.cs new file mode 100644 index 0000000..d090367 --- /dev/null +++ b/Web/App_Code/EmployeeProxy.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Configuration; +using System.Collections.Generic; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; +using BLL; +using Model; + +//该源码下载自www.51aspx.com(51aspx.com) +/// diff --git a/Web/App_Code/PersonProxy.cs b/Web/App_Code/PersonProxy.cs new file mode 100644 index 0000000..5033aae --- /dev/null +++ b/Web/App_Code/PersonProxy.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Configuration; +using System.Collections.Generic; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; +using BLL; +using Model; + +/// +/// PersonProxy 的摘要说明 diff --git a/Web/App_Data/ORMappings/DepartmentInfo.xml b/Web/App_Data/ORMappings/DepartmentInfo.xml new file mode 100644 index 0000000..af8c001 --- /dev/null +++ b/Web/App_Data/ORMappings/DepartmentInfo.xml @@ -0,0 +1,15 @@ + + + + + + SELECT t1.DepartmentID,t1.DepartmentName + FROM Department t1 INNER JOIN Employee t2 + ON t1.DepartmentID=t2.DepartmentID + WHERE t2.EmployeeID={0} + + + + + + diff --git a/Web/App_Data/ORMappings/EmployeeInfo.xml b/Web/App_Data/ORMappings/EmployeeInfo.xml new file mode 100644 index 0000000..ade3cdb --- /dev/null +++ b/Web/App_Data/ORMappings/EmployeeInfo.xml @@ -0,0 +1,15 @@ + + + + + + SELECT t1.EmployeeId, t1.FirstName, t1.LastName, t1.Age, t2.DepartmentName + FROM Employee AS t1,Department AS t2 + WHERE t1.DepartmentID=t2.DepartmentID AND FirstName LIKE '%{0}%' + ORDER BY t1.EmployeeId DESC + + + + + + diff --git a/Web/App_Data/ORMappings/PersonInfo.xml b/Web/App_Data/ORMappings/PersonInfo.xml new file mode 100644 index 0000000..5b60412 --- /dev/null +++ b/Web/App_Data/ORMappings/PersonInfo.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/Web/Default.aspx b/Web/Default.aspx new file mode 100644 index 0000000..d037ca3 --- /dev/null +++ b/Web/Default.aspx @@ -0,0 +1,15 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> + + + + + Untitled Page + + +
+ +
+ + diff --git a/Web/Default.aspx.cs b/Web/Default.aspx.cs new file mode 100644 index 0000000..2b4fc2f --- /dev/null +++ b/Web/Default.aspx.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Configuration; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; + +using Model; + +public partial class _Default : System.Web.UI.Page +{ diff --git a/Web/Employee.aspx b/Web/Employee.aspx new file mode 100644 index 0000000..f3631b9 --- /dev/null +++ b/Web/Employee.aspx @@ -0,0 +1,15 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Employee.aspx.cs" Inherits="Employee" %> + + + + + Employee + + +
+
+ Back To Default.aspx
+ Employee Demo : Select,Delete,Update,Insert,Select by one condition. + +
diff --git a/Web/Employee.aspx.cs b/Web/Employee.aspx.cs new file mode 100644 index 0000000..fefc896 --- /dev/null +++ b/Web/Employee.aspx.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Configuration; +using System.Collections.Generic; +using System.Collections; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; +using Model; + +public partial class Employee : System.Web.UI.Page +{ diff --git a/Web/Person.aspx b/Web/Person.aspx new file mode 100644 index 0000000..6b7001f --- /dev/null +++ b/Web/Person.aspx @@ -0,0 +1,15 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Person.aspx.cs" Inherits="Person" %> + + + + + + 无标题页 + + + +
+ +
+ + diff --git a/Web/Person.aspx.cs b/Web/Person.aspx.cs new file mode 100644 index 0000000..93cacc5 --- /dev/null +++ b/Web/Person.aspx.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Configuration; +using System.Collections.Generic; +using System.Collections; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; +using Model; + +//该源码下载自www.51aspx.com(51aspx.com) +public partial class Person : System.Web.UI.Page diff --git a/Web/Web.config b/Web/Web.config new file mode 100644 index 0000000..d3b665f --- /dev/null +++ b/Web/Web.config @@ -0,0 +1,15 @@ + + + + + + + +