mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Update demo
This commit is contained in:
parent
3ae7f9fecb
commit
b6a747dbf2
@ -34,6 +34,11 @@ namespace OrmTest
|
||||
{
|
||||
Console.WriteLine(column.DbColumnName);
|
||||
}
|
||||
|
||||
var dbColumnsName = db.EntityMaintenance.GetDbColumnName<EntityMapper>("Name");
|
||||
|
||||
var dbTableName = db.EntityMaintenance.GetTableName<EntityMapper>();
|
||||
|
||||
//more https://github.com/sunkaixuan/SqlSugar/wiki/9.EntityMain
|
||||
Console.WriteLine("#### EntityMain End ####");
|
||||
}
|
||||
|
15
Src/Asp.Net/SqlServerTest/Models/EntityMapper.cs
Normal file
15
Src/Asp.Net/SqlServerTest/Models/EntityMapper.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
namespace OrmTest
|
||||
{
|
||||
[SugarTable("MyEntityMapper")]
|
||||
public class EntityMapper
|
||||
{
|
||||
[SugarColumn(ColumnName ="MyName")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -68,6 +68,7 @@
|
||||
<Compile Include="Demo\DemoF_Utilities.cs" />
|
||||
<Compile Include="Demo\DemoG_SimpleClient.cs" />
|
||||
<Compile Include="Models\Custom.cs" />
|
||||
<Compile Include="Models\EntityMapper.cs" />
|
||||
<Compile Include="Models\Mapper.cs" />
|
||||
<Compile Include="Models\Tree.cs" />
|
||||
<Compile Include="Models\AttributeTable.cs" />
|
||||
|
@ -46,7 +46,12 @@ namespace SqlSugar
|
||||
public string GetTableName<T>()
|
||||
{
|
||||
var typeName = typeof(T).Name;
|
||||
if (this.Context.MappingTables == null || this.Context.MappingTables.Count == 0) return typeName;
|
||||
if (this.Context.MappingTables == null || this.Context.MappingTables.Count == 0)
|
||||
{
|
||||
var entity = this.GetEntityInfo<T>();
|
||||
if (entity.DbTableName.HasValue()) return entity.DbTableName;
|
||||
else return entity.EntityName;
|
||||
}
|
||||
else
|
||||
{
|
||||
var mappingInfo = this.Context.MappingTables.SingleOrDefault(it => it.EntityName == typeName);
|
||||
@ -56,7 +61,12 @@ namespace SqlSugar
|
||||
public string GetTableName(Type entityType)
|
||||
{
|
||||
var typeName = entityType.Name;
|
||||
if (this.Context.MappingTables == null || this.Context.MappingTables.Count == 0) return typeName;
|
||||
if (this.Context.MappingTables == null || this.Context.MappingTables.Count == 0)
|
||||
{
|
||||
var entity = this.GetEntityInfo(entityType);
|
||||
if (entity.DbTableName.HasValue()) return entity.DbTableName;
|
||||
else return entity.EntityName;
|
||||
}
|
||||
else
|
||||
{
|
||||
var mappingInfo = this.Context.MappingTables.SingleOrDefault(it => it.EntityName == typeName);
|
||||
@ -87,7 +97,12 @@ namespace SqlSugar
|
||||
var isAny = this.GetEntityInfo<T>().Columns.Any(it => it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
|
||||
Check.Exception(!isAny, "Property " + propertyName + " is Invalid");
|
||||
var typeName = typeof(T).Name;
|
||||
if (this.Context.MappingColumns == null || this.Context.MappingColumns.Count == 0) return propertyName;
|
||||
if (this.Context.MappingColumns == null || this.Context.MappingColumns.Count == 0)
|
||||
{
|
||||
var column= this.GetEntityInfo<T>().Columns.First(it => it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
|
||||
if (column.DbColumnName.HasValue()) return column.DbColumnName;
|
||||
else return column.PropertyName;
|
||||
}
|
||||
else
|
||||
{
|
||||
var mappingInfo = this.Context.MappingColumns.SingleOrDefault(it => it.EntityName == typeName && it.PropertyName == propertyName);
|
||||
@ -99,7 +114,12 @@ namespace SqlSugar
|
||||
var isAny = this.GetEntityInfo(entityType).Columns.Any(it => it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
|
||||
Check.Exception(!isAny, "Property " + propertyName + " is Invalid");
|
||||
var typeName = entityType.Name;
|
||||
if (this.Context.MappingColumns == null || this.Context.MappingColumns.Count == 0) return propertyName;
|
||||
if (this.Context.MappingColumns == null || this.Context.MappingColumns.Count == 0)
|
||||
{
|
||||
var column = this.GetEntityInfo(entityType).Columns.First(it => it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
|
||||
if (column.DbColumnName.HasValue()) return column.DbColumnName;
|
||||
else return column.PropertyName;
|
||||
}
|
||||
else
|
||||
{
|
||||
var mappingInfo = this.Context.MappingColumns.SingleOrDefault(it => it.EntityName == typeName && it.PropertyName == propertyName);
|
||||
|
Loading…
Reference in New Issue
Block a user