init lserp cs 5.0
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
|
||||
using Zhaizj.Framework.Data;
|
||||
|
||||
namespace Zhaizj.Framework.ORM.Operation {
|
||||
|
||||
internal class FindRelationOperation {
|
||||
|
||||
private static readonly ILog logger = LogManager.GetLogger( typeof( FindRelationOperation ) );
|
||||
|
||||
public static IList FindDataOther( Type throughType, Type t, String order, int id ) {
|
||||
|
||||
// 1029
|
||||
ObjectInfo state = new ObjectInfo( throughType );
|
||||
String relationPropertyName = state.EntityInfo.GetRelationPropertyName( t );
|
||||
EntityPropertyInfo info = state.EntityInfo.FindRelationProperty( t );
|
||||
state.Order = order;
|
||||
state.include( info.Name );
|
||||
return ObjectDB.Find( state, relationPropertyName + ".Id=" + id ).listChildren( info.Name );
|
||||
|
||||
}
|
||||
|
||||
public static String GetSameTypeIds( Type throughType, Type t, int id ) {
|
||||
|
||||
// 1029
|
||||
ObjectInfo state = new ObjectInfo( throughType );
|
||||
String relationPropertyName = state.EntityInfo.GetRelationPropertyName( t );
|
||||
EntityPropertyInfo info = state.EntityInfo.FindRelationProperty( t );
|
||||
String ids = ObjectDB.Find(state, relationPropertyName + ".Id=" + id ).get( info.Name + ".Id" );
|
||||
EntityPropertyInfo property = state.EntityInfo.GetProperty( relationPropertyName );
|
||||
|
||||
|
||||
String sql = String.Format( "select distinct {0} from {1} where {2} in ({3}) and {0}<>{4}", property.ColumnName, state.EntityInfo.TableName, info.ColumnName, ids, id );
|
||||
|
||||
IDbCommand command = DataFactory.GetCommand( sql, DbContext.getConnection( state.EntityInfo ) );
|
||||
IDataReader rd = null;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
try {
|
||||
rd = command.ExecuteReader();
|
||||
while (rd.Read()) {
|
||||
builder.Append( rd[0] );
|
||||
builder.Append( "," );
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
logger.Error( exception.Message );
|
||||
throw exception;
|
||||
}
|
||||
finally {
|
||||
OrmHelper.CloseDataReader( rd );
|
||||
}
|
||||
return builder.ToString().TrimEnd( ',' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user