本文整理汇总了C#中wojilu.ORM.EntityPropertyInfo类的典型用法代码示例。如果您正苦于以下问题:C# EntityPropertyInfo类的具体用法?C# EntityPropertyInfo怎么用?C# EntityPropertyInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityPropertyInfo类属于wojilu.ORM命名空间,在下文中一共展示了EntityPropertyInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Validate
public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result )
{
Object obj = target.get( info.Name );
Boolean isNull = false;
if (info.Type == typeof( String )) {
if (obj == null) {
isNull = true;
}
else if (strUtil.IsNullOrEmpty( obj.ToString() )) {
isNull = true;
}
}
else if (obj == null) {
isNull = true;
}
if (isNull) {
if (strUtil.HasText( this.Message )) {
result.Add( this.Message );
}
else {
EntityInfo ei = Entity.GetInfo( target );
String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
result.Add( str + "can not be null" );
}
}
}
示例2: checkLength
private static Boolean checkLength( EntityPropertyInfo info )
{
if (info.SaveAttribute == null) return false;
if (info.SaveAttribute.LengthSetted() == false) return false;
if (info.Type != typeof( String )) return false;
return true;
}
示例3: addColumnSingle
private void addColumnSingle( EntityInfo entity, StringBuilder sb, EntityPropertyInfo ep, String columnName ) {
if (ep.Type == typeof( int )) {
addColumn_Int( sb, ep, columnName );
}
else if (ep.Type == typeof( long )) {
addColumn_Long( sb, columnName );
}
else if (ep.Type == typeof( DateTime )) {
addColumn_Time( sb, columnName );
}
else if (ep.Type == typeof( decimal )) {
addColumn_Decimal( entity, sb, ep, columnName );
}
else if (ep.Type == typeof( double )) {
addColumn_Double( entity, sb, columnName );
}
else if (ep.Type == typeof( float )) {
addColumn_Single( entity, sb, columnName );
}
else if (ep.Type == typeof( String )) {
addColumn_String( entity, sb, ep, columnName );
}
else if (ep.IsEntity) {
addColumn_entity( sb, columnName );
}
}
示例4: addColumn_Int
protected override void addColumn_Int( StringBuilder sb, EntityPropertyInfo ep, String columnName ) {
sb.Append( columnName );
if (ep.Property.IsDefined( typeof( TinyIntAttribute ), false )) {
sb.Append( " tinyint default 0, " );
}
else {
sb.Append( " int default 0, " );
}
}
示例5: addColumn_ByColumnAttribute
protected virtual void addColumn_ByColumnAttribute( EntityInfo entity, StringBuilder sb, EntityPropertyInfo ep, String columnName )
{
if (ep.SaveAttribute.Length < 255) {
addColumn_ShortText( sb, columnName, ep.SaveAttribute.Length );
}
else if ((ep.SaveAttribute.Length > 255) && (ep.SaveAttribute.Length < 4000)) {
addColumn_MiddleText( entity, sb, ep, columnName );
}
else {
addColumn_LongText( entity, sb, columnName );
}
}
示例6: addColumn_Decimal
protected override void addColumn_Decimal( EntityInfo entity, StringBuilder sb, EntityPropertyInfo ep, String columnName ) {
if (ep.MoneyAttribute != null) {
sb.Append( columnName );
sb.Append( " currency default 0, " );
}
else {
DecimalAttribute da = ep.DecimalAttribute;
if (da == null) throw new Exception( "DecimalAttribute not found=" + entity.FullName + "_" + ep.Name );
sb.Append( columnName );
sb.Append( " decimal(" + da.Precision + "," + da.Scale + ") default 0, " );
}
}
示例7: setEntityPropertyValueById
private static void setEntityPropertyValueById( IEntity obj, ObjectInfo state, EntityPropertyInfo property, int pid )
{
if (!property.IsAbstractEntity) {
IEntity objValue = Entity.New( property.Type.FullName );
objValue.Id = pid;
// state
//objValue.state = new ObjectInfo( property.Type ).Copy( state );
IEntity objCache = ObjectPool.FindOne( property.Type, objValue.Id );
if (objCache != null) {
objValue = objCache;
}
obj.set( property.Name, objValue );
}
}
示例8: isContinue
private static Boolean isContinue( String action, EntityPropertyInfo info, EntityInfo entityInfo )
{
if (info.SaveToDB == false) return true;
if (info.IsList) return true;
if (info.Name.Equals( "Id" )) {
if (action.Equals( "update" )) return true;
if (action.Equals( "insert" ) && entityInfo.Parent == null) return true;
}
return false;
}
示例9: Validate
public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result )
{
if (!Regex.IsMatch( cvt.ToNotNull( target.get( info.Name ) ), this.Regexp, RegexOptions.Singleline )) {
if (strUtil.HasText( this.Message )) {
result.Add( this.Message );
}
else {
EntityInfo ei = Entity.GetInfo( target );
String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
result.Add( str + " is not match the format pattern : " + this.Regexp );
}
}
}
示例10: Validate
public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result )
{
Object obj = target.get( info.Name );
EntityInfo ei = Entity.GetInfo( target );
int count = getCount( action, target, ei, info, obj );
if (count > 0) {
if (strUtil.HasText( this.Message )) {
result.Add( this.Message );
}
else {
String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
result.Add( str + " should be unique, but it has been in database" );
}
}
}
示例11: getCount
private static int getCount( String action, IEntity target, EntityInfo entityInfo, EntityPropertyInfo info, Object obj )
{
if (obj == null) return 1;
String usql;
IDatabaseDialect dialect = entityInfo.Dialect;
if (action.Equals( "update" )) {
usql = String.Format( "select count(Id) from {0} where Id<>{3} and {1}={2}", entityInfo.TableName, info.ColumnName, dialect.GetParameter( info.Name ), target.Id );
}
else {
usql = String.Format( "select count(Id) from {0} where {1}={2}", entityInfo.TableName, info.ColumnName, dialect.GetParameter( info.Name ) );
}
logger.Info( LoggerUtil.SqlPrefix + " validate unique sql : " + usql );
IDbCommand cmd = DataFactory.GetCommand( usql, DbContext.getConnection( entityInfo ) );
DataFactory.SetParameter( cmd, info.ColumnName, obj );
return cvt.ToInt( cmd.ExecuteScalar() );
}
示例12: isContinue
private static Boolean isContinue( String action, EntityPropertyInfo info, EntityInfo entityInfo )
{
if (info.SaveToDB == false) return true;
if (info.IsList) return true;
if (info.Name.Equals( "Id" )) {
if (action.Equals( "update" )) return true;
// ����ʵ�������ʶ��
if (/**/DbConfig.Instance.IsAutoId && action.Equals("insert")
&& entityInfo.Parent == null
)
return true;
}
return false;
}
示例13: AddPropertyToHashtable
internal void AddPropertyToHashtable( EntityPropertyInfo p )
{
_propertyHashTable[p.Name] = p;
if (strUtil.HasText( p.ColumnName )) {
_propertyHashTableByColumn[p.ColumnName.ToLower()] = p;
}
}
示例14: getEntityPropertyName
private string getEntityPropertyName( EntityPropertyInfo ep, object propertyValue ) {
IEntity pValue = propertyValue as IEntity;
if (pValue == null) return "";
string val = null;
EntityInfo ei = Entity.GetInfo( pValue );
if ((ei.GetProperty( "Name" ) != null) && (pValue.get( "Name" ) != null)) {
val = pValue.get( "Name" ).ToString();
}
else if ((ei.GetProperty( "Title" ) != null) && (pValue.get( "Title" ) != null)) {
val = pValue.get( "Title" ).ToString();
}
if (strUtil.HasText( val )) {
String lnk = to( Model ) + "?typeName=" + ep.ParentEntityInfo.FullName + "&p=" + ep.Name + "&id=" + pValue.Id;
return "<a title=\"" + ep.Type.FullName + ", Id=" + pValue.Id + "\" href=\"" + lnk + "\">" + val + "</a>";
}
else {
return ep.Type.Name + "_" + pValue.Id;
}
}
示例15: getPropertyValue
private string getPropertyValue( IEntity obj, EntityPropertyInfo ep ) {
object val = obj.get( ep.Name );
if (val == null) {
return "";
}
return val.ToString();
}