init lserp cs 5.0
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using Zhaizj.Framework;
|
||||
using Zhaizj.Framework.Log;
|
||||
using System.Data;
|
||||
|
||||
namespace Zhaizj.Framework.ORM.Operation
|
||||
{
|
||||
|
||||
|
||||
internal class FindAllOperation
|
||||
{
|
||||
|
||||
private static readonly ILog logger = LogManager.GetLogger(typeof(FindAllOperation));
|
||||
|
||||
public static IList FindAll(ObjectInfo state)
|
||||
{
|
||||
IList parentResults = findAllPrivate(state);
|
||||
if (state.EntityInfo.ChildEntityList.Count > 0)
|
||||
{
|
||||
return findAllFromChild(parentResults, state);
|
||||
}
|
||||
return parentResults;
|
||||
}
|
||||
|
||||
public static DataTable FindDt(ObjectInfo state, string orderby)
|
||||
{
|
||||
String sql = "select * from " + state.EntityInfo.TableName + " order by " + orderby;
|
||||
logger.Info(LoggerUtil.SqlPrefix + "[" + state.EntityInfo.Name + "_FindDt]" + sql);
|
||||
return EntityPropertyUtil.FindDt(state, sql);
|
||||
}
|
||||
|
||||
public static DataTable FindDt(ObjectInfo state)
|
||||
{
|
||||
String sql = "select * from " + state.EntityInfo.TableName;
|
||||
logger.Info(LoggerUtil.SqlPrefix + "[" + state.EntityInfo.Name + "_FindDt]" + sql);
|
||||
return EntityPropertyUtil.FindDt(state, sql);
|
||||
}
|
||||
|
||||
|
||||
public static int findMaxId(ObjectInfo state)
|
||||
{
|
||||
String sql = "select max(id) as id from " + state.EntityInfo.TableName;
|
||||
logger.Info(LoggerUtil.SqlPrefix + "[" + state.EntityInfo.Name + "_FindDt]" + sql);
|
||||
return EntityPropertyUtil.FindMaxId(state, sql);
|
||||
}
|
||||
|
||||
public static DataTable FindDt(String condtion, ObjectInfo state, string orderby)
|
||||
{
|
||||
String sql = "select * from " + state.EntityInfo.TableName + " where " + condtion + " order by " + orderby;
|
||||
logger.Info(LoggerUtil.SqlPrefix + "[" + state.EntityInfo.Name + "_FindDt]" + sql);
|
||||
return EntityPropertyUtil.FindDt(state, sql);
|
||||
}
|
||||
public static DataTable FindDt(string fields, String condtion, ObjectInfo state, string orderby)
|
||||
{
|
||||
String sql = "select " + fields + " from " + state.EntityInfo.TableName + " where " + condtion + " order by " + orderby;
|
||||
logger.Info(LoggerUtil.SqlPrefix + "[" + state.EntityInfo.Name + "_FindDt]" + sql);
|
||||
return EntityPropertyUtil.FindDt(state, sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static IList findAllPrivate(ObjectInfo state)
|
||||
{
|
||||
|
||||
String sql = "select * from " + state.EntityInfo.TableName;
|
||||
logger.Info(LoggerUtil.SqlPrefix + "[" + state.EntityInfo.Name + "_FindAll]" + sql);
|
||||
|
||||
return EntityPropertyUtil.FindList(state, sql);
|
||||
}
|
||||
|
||||
private static IList findAllFromChild(IList parents, ObjectInfo state)
|
||||
{
|
||||
|
||||
ArrayList results = new ArrayList();
|
||||
|
||||
foreach (EntityInfo info in state.EntityInfo.ChildEntityList)
|
||||
{
|
||||
|
||||
ObjectInfo childState = new ObjectInfo(info);
|
||||
childState.includeAll();
|
||||
IList children = ObjectDB.FindAll(childState);
|
||||
|
||||
for (int i = 0; i < children.Count; i++)
|
||||
{
|
||||
IEntity child = children[i] as IEntity;
|
||||
// state
|
||||
//child.state.Order = state.Order;
|
||||
results.Add(child);
|
||||
parents.RemoveAt(Query.getIndexOfObject(parents, child));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (parents.Count > 0) results.AddRange(parents);
|
||||
results.Sort();
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user