using Castle.ActiveRecord; using NHibernate.Criterion; using System; using System.Text; namespace BizCom { [ActiveRecord("CE_ErpUserPost")] public class CeErpUserPost : ComBase { /// /// /// [PrimaryKey(PrimaryKeyType.Native)] public int ID { get; set; } private int _userID = 0; /// /// /// [Property] public int UserID { get { return _userID; } set { _userID = value; } } private int _orgID = 0; /// /// /// [Property] public int OrgID { get { return _orgID; } set { _orgID = value; } } private CeErpPost _post; [BelongsTo("PostID", Insert = false, NotFoundBehaviour = NotFoundBehaviour.Ignore, Cascade = CascadeEnum.None, Update = false)] public CeErpPost Post { get { return _post; } set { _post = value; } } private int _postID = 0; /// /// /// [Property] public int PostID { get { return _postID; } set { _postID = value; } } public static void Del(object id) { StringBuilder sql = new StringBuilder(); sql.AppendFormat("delete from CE_ErpUserPost where id=" + id); ExecuteNonQuery(sql.ToString()); } public static void Del(object id, string personId) { StringBuilder sql = new StringBuilder(); sql.AppendFormat("delete from CE_ErpUserPost where id={0} and UserID={1}", id, personId); ExecuteNonQuery(sql.ToString()); } public static CeErpUserPost Get(int personId, object id) { return FindFirst(Expression.And(Expression.Eq("UserID", personId), Expression.Eq("ID", Convert.ToInt32(id)))); //Expression.Sql(string.Format("PersonID={0} and ID={1}", personId, id))); } public static CeErpUserPost GetByUserID(int uid) { return FindFirst(Expression.Eq("UserID", uid)); //Expression.Sql(string.Format("PersonID={0} and ID={1}", personId, id))); } } }