using PWMIS.DataMap.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PWMIS.Common; namespace GoOver.Models
{
[Serializable()]
public partial class Stu : EntityBase
{
public Stu()
{
TableName = "Stu";
Schema = "";
EntityMap = EntityMapType.Table;
//IdentityName = "标识字段名";
IdentityName = "Id";
//PrimaryKeys.Add("主键字段名");
PrimaryKeys.Add("Id");
}
protected override void SetFieldNames()
{
PropertyNames = new string[] { "Id", "Name", "Sex", "CreateTime", "IsDelete" };
} protected override string[] SetFieldDescriptions()
{
//字段对应的描述
return new string[] { "主键", "名称", "性别", "创建时间", "删除标志" };
}
public System.Int32 Id
{
get { return getProperty<System.Int32>("Id"); }
set { setProperty("Id", value); }
}
public System.String Name
{
get { return getProperty<System.String>("Name"); }
set { setProperty("Name", value); }
}
public System.Boolean Sex
{
get { return getProperty<System.Boolean>("Sex"); }
set { setProperty("Sex", value); }
}
public System.DateTime CreateTime
{
get { return getProperty<System.DateTime>("CreateTime"); }
set { setProperty("CreateTime", value); }
}
public System.Boolean IsDelete
{
get { return getProperty<System.Boolean>("IsDelete"); }
set { setProperty("IsDelete", value); }
}
}
}

PDF.NET SOD连接数据库只支持明文写在config文件的:

<configuration>
<connectionStrings>
<add name="StudentDB" connectionString="Data Source=.;Initial Catalog=StudentDB;Integrated Security=False;User ID=sa;Password=123;max pool size=1" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

可以研究下这个:https://blog.csdn.net/qqcxw/article/details/51927469

//查询:
UserTab user = new UserTab(){UserID = };
OQL q=OQL.From(User).select().Where(User.UserID).END;
UserTab dbUser = EntityQuery<UserTab>.QueryObject(q);
//查询2:
List<Stu> LStu = new List<Stu>();
var StuList = OQL.FromObject<Stu>().Select().Where((x, c) => x.Comparer(c.IsDelete, "=", false)).END.ToList();
//删除:相当于:Delete from [UserTab] where [UserID] = 2
UserTab user = new UserTab();
OQL deleteQ = OQL.From(user).Delete().Where(cmp => cmp.Comparer(user.UserID,OQLCompare.comUserTab>.Instance.ExecuteOql(deleteQ);
//更新整个实体:
UserTab user = new UserTab(){UserID = ,UserName = "张三",pwd="XXX"};
//更新某个字段:相当于:update [UserTab] set [UserName] = "李四",[pwd] = "XXX" where [UserID] = 1
UserTab user = new UserTab(){UserID = ,UserName="李四",pwd="XXX"};
OQL updateQ = OQL.From(user).Update(user.UserName).END;
EntityQuery<UserTab>.Instance.ExecuteOql(updateQ);//只更新姓名
//插入全部数据:
UserTab user = new UserTab(){UserName = "张三",pwd="XXX"};
EntityQuery<UserTab>.Instance.Insert(user);
//插入部分数据:
UserTab user = new UserTab(){UserName = "张三",pwd="XXX"};
OQL insertQ = OQL.From(user).Insert(user.UserName).END;
EntityQuery<UserTab>.Instance.ExecuteOql(insertQ);
05-11 00:04