SqlSugar源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.4 KiB

7 years ago
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()
{
Where();
OrderBy();
}
private static void Where()
{
var db = GetInstance();
//Parameterized processing
string value = "'jack';drop table Student";
7 years ago
var list = db.Queryable<Student>().Where("name=:name", new { name = value }).ToList();
7 years ago
//Nothing happened
}
private static void OrderBy()
{
var db = GetInstance();
//propertyName is valid
string propertyName = "Id";
string dbColumnName = db.EntityMaintenance.GetDbColumnName<Student>(propertyName);
7 years ago
var list = db.Queryable<Student>().OrderBy(dbColumnName).ToList();
//propertyName is invalid
try
{
propertyName = "Id'";
dbColumnName = db.EntityMaintenance.GetDbColumnName<Student>(propertyName);
7 years ago
var list2 = db.Queryable<Student>().OrderBy(dbColumnName).ToList();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}