master
editor 1 week ago
commit ee0e9b9aac

@ -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

@ -0,0 +1,15 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6B617321-254B-4789-B487-A352852B8CBA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BLL</RootNamespace>
<AssemblyName>BLL</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Model;
namespace BLL
{
public class Department : ObjectStore<DepartmentInfo>
{
public static Department TheInstance = new Department();
public Department()
{ }

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Model;
namespace BLL
{
public class Employee : ObjectStore<EmployeeInfo>
{
public static Employee TheInstance = new Employee();
public Employee()
{ }

@ -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<T>
{
//public static ObjectStore<T> TheInstance = new ObjectStore<T>();

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Model;
namespace BLL
{
public class Person : ObjectStore<PersonInfo>
{
public static Person TheInstance = new Person();
public Person()
{ }

@ -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("")]

@ -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

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]

@ -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

@ -0,0 +1,15 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6B617321-254B-4789-B487-A352852B8CBA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BLL</RootNamespace>
<AssemblyName>BLL</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Model;
namespace BLL
{
public class Department : ObjectStore<DepartmentInfo>
{
public static Department TheInstance = new Department();
public Department()
{ }

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Model;
namespace BLL
{
public class Employee : ObjectStore<EmployeeInfo>
{
public static Employee TheInstance = new Employee();
public Employee()
{ }

@ -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<T>
{
//public static ObjectStore<T> TheInstance = new ObjectStore<T>();

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Model;
namespace BLL
{
public class Person : ObjectStore<PersonInfo>
{
public static Person TheInstance = new Person();
public Person()
{ }

@ -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("")]

@ -0,0 +1,15 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B3F86D52-6F47-4F6A-ABFD-15C2004785F6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DAL</RootNamespace>
<AssemblyName>DAL</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>

@ -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<string, DbCommand> _commandCache = new Dictionary<string, DbCommand>();

@ -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"];

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Runtime.Serialization;
using System.Xml;
using System.IO;
//<2F><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>www.51aspx.com(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
namespace DAL
{
public class MappingStore
{
private Dictionary<string, MappingInfo> __mappings = new Dictionary<string, MappingInfo>();

@ -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)

@ -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<T>
{
#region Query
//public static T Select(params object[] keys)

@ -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 <20> CT 2005")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

@ -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<T, U> where T : new()
{
private Type _type;
private T _obj;

@ -0,0 +1,15 @@
using System;
namespace Model
{
/// <summary>
///
/// </summary>
public class DepartmentInfo
{
private int _departmentID;
private string _departmentName;
/// <summary>
/// Ĭ<>Ϲ<EFBFBD><CFB9><EFBFBD><ECBAAF>
/// </summary>

@ -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;

@ -0,0 +1,15 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{71F8A2BA-BACA-495E-8EDF-E8A452C7F049}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Model</RootNamespace>
<AssemblyName>Model</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>

@ -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;

@ -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("")]

@ -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":[]}

@ -0,0 +1,15 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B3F86D52-6F47-4F6A-ABFD-15C2004785F6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DAL</RootNamespace>
<AssemblyName>DAL</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>

@ -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<string, DbCommand> _commandCache = new Dictionary<string, DbCommand>();

@ -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"];

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Runtime.Serialization;
using System.Xml;
using System.IO;
//<2F><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>www.51aspx.com(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
namespace DAL
{
public class MappingStore
{
private Dictionary<string, MappingInfo> __mappings = new Dictionary<string, MappingInfo>();

@ -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)

@ -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<T>
{
#region Query
//public static T Select(params object[] keys)

@ -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 <20> CT 2005")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

@ -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<T, U> where T : new()
{
private Type _type;
private T _obj;

@ -0,0 +1,5 @@
bin\Debug\CodeGenerator.dll
bin\Debug\CodeGenerator.pdb
obj\Debug\ResolveAssemblyReference.cache
obj\Debug\CodeGenerator.dll
obj\Debug\CodeGenerator.pdb

@ -0,0 +1,5 @@
bin\Debug\DAL.dll
bin\Debug\DAL.pdb
obj\Debug\ResolveAssemblyReference.cache
obj\Debug\DAL.dll
obj\Debug\DAL.pdb

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]

@ -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

@ -0,0 +1,15 @@
using System;
namespace Model
{
/// <summary>
///
/// </summary>
public class DepartmentInfo
{
private int _departmentID;
private string _departmentName;
/// <summary>
/// Ĭ<>Ϲ<EFBFBD><CFB9><EFBFBD><ECBAAF>
/// </summary>

@ -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;

@ -0,0 +1,15 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{71F8A2BA-BACA-495E-8EDF-E8A452C7F049}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Model</RootNamespace>
<AssemblyName>Model</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>

@ -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;

@ -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("")]

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]

@ -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

@ -0,0 +1,5 @@
obj\Debug\ResolveAssemblyReference.cache
bin\Debug\Model.dll
bin\Debug\Model.pdb
obj\Debug\Model.dll
obj\Debug\Model.pdb

@ -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

@ -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;
/// <summary>
/// DepartmentProxy 的摘要说明

@ -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()
/// <summary>

@ -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;
/// <summary>
/// PersonProxy 的摘要说明

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<object.mappings>
<object.mapping for="DepartmentInfo" namespace="Model">
<command type="SelectOne">
<text>
SELECT t1.DepartmentID,t1.DepartmentName
FROM Department t1 INNER JOIN Employee t2
ON t1.DepartmentID=t2.DepartmentID
WHERE t2.EmployeeID={0}
</text>
<parameters>
<add objMember="_departmentID" dbMember="DepartmentID"/>
<add objMember="_departmentName" dbMember="DepartmentName" />
</parameters>
</command>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<object.mappings>
<object.mapping for="EmployeeInfo" namespace="Model">
<command type="SelectOne">
<text>
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
</text>
<parameters>
<add objMember="_employeeId" dbMember="EmployeeId"/>
<add objMember="_firstName" dbMember="FirstName" />
<add objMember="_lastName" dbMember="LastName" />
<add objMember="_age" dbMember="Age" />

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<object.mappings>
<object.mapping for="PersonInfo" namespace="Model">
<!--<command type="Select">
<text>
SELECT id, firstName, lastName
FROM Person where id={0}
</text>
<parameters>
<add objMember="_firstName" dbMember="FirstName" />
<add objMember="_lastName" dbMember="LastName" />
</parameters>
</command>-->
<command type="Insert">
<text>

@ -0,0 +1,15 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="Employee.aspx">Employee.aspx</a><br />
<a href="Person.aspx">Person.aspx</a>&nbsp;&nbsp;<br /> <a href="http://www.51aspx.com" target="_blank">download from 51aspx.com</a></div>
</form>
</body>
</html>

@ -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
{

@ -0,0 +1,15 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Employee.aspx.cs" Inherits="Employee" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Employee</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Back To <a href="Default.aspx">Default.aspx</a><br />
Employee Demo : Select,Delete,Update,Insert,Select by one condition.<table style="width: 685px"
border="1">
<tr>
<td colspan="2">

@ -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
{

@ -0,0 +1,15 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Person.aspx.cs" Inherits="Person" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body bgcolor="gray">
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="一次添加三条数据" />
<asp:Label ID="Label1" runat="server"></asp:Label></div>
</form>
</body>

@ -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()
public partial class Person : System.Web.UI.Page

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="DBName" value="myDB"/>
<add key="KeyEmployee" value="KeyEmployee"/>
</appSettings>
<connectionStrings>
Loading…
Cancel
Save