mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 14:04:44 +08:00
37 lines
1016 B
C#
37 lines
1016 B
C#
using OrmTest.Demo;
|
|
using OrmTest.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace OrmTest.Demo
|
|
{
|
|
/// <summary>
|
|
/// Secure string operations
|
|
/// </summary>
|
|
public class JoinSql : DemoBase
|
|
{
|
|
public static void Init()
|
|
{
|
|
var db = GetInstance();
|
|
//propertyName is valid
|
|
string propertyName = "Id";
|
|
string dbColumnName = db.EntityProvider.GetDbColumnName<Student>(propertyName);
|
|
var list = db.Queryable<Student>().OrderBy(dbColumnName).ToList();
|
|
|
|
//propertyName is invalid
|
|
try
|
|
{
|
|
propertyName = "Id'";
|
|
dbColumnName = db.EntityProvider.GetDbColumnName<Student>(propertyName);
|
|
var list2 = db.Queryable<Student>().OrderBy(dbColumnName).ToList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|