public virtual string GetLoadColumnPropertySql(PropertyInfo prop) { StringBuilder sb = new StringBuilder(); ColumnAttribute col = prop.GetColumnAttribute(); sb.Append("select "); if (!string.IsNullOrWhiteSpace(col.SQL)) { sb.Append("(" + col.SQL + ") as "); } sb.Append(col.Name); sb.Append(" from "); sb.Append(prop.DeclaringType.GetTableAttribute().Name); sb.Append(" where "); sb.Append(prop.DeclaringType.GetIdProperty().GetColumnAttribute().Name); sb.Append("=?"); return sb.ToString(); }
private static bool NeedProxy(PropertyInfo prop, bool enableLazy, bool enforceLazy) { ColumnAttribute col = prop.GetColumnAttribute(); if (col != null && col.LazyLoad && enableLazy) { return true; } ManyToOneAttribute manyToOne = prop.GetManyToOneAttribute(); if (manyToOne != null && (manyToOne.LazyLoad && enableLazy || enforceLazy)) { return true; } OneToManyAttribute oneToMany = prop.GetOneToManyAttribute(); if (oneToMany != null && (oneToMany.LazyLoad && enableLazy || enforceLazy)) { return true; } ManyToManyAttribute manyToMany = prop.GetManyToManyAttribute(); if (manyToMany != null && (manyToMany.LazyLoad && enableLazy || enforceLazy)) { return true; } return false; }