示例#1
0
        /// <summary>
        /// 得到远程查询条件
        /// </summary>
        /// <param name="infos"></param>
        /// <param name="remoteQuery"></param>
        /// <param name="property"></param>
        /// <returns></returns>
        protected virtual QueryInfo GetRemoteQuery(IEnumerable <EntityInfo> infos, RemoteQueryInfo remoteQuery, OrmPropertyInfo property)
        {
            var query = new QueryInfo {
                SelectExp = remoteQuery.SelectExp, Parameters = remoteQuery.Parameters, OrderByExp = remoteQuery.OrderByExp
            };
            var pName = "_Ids";
            var ids   =
                (from object info in infos select info.GetProperty(property.Map.ObjectProperty.PropertyName)).ToArray();

            query.Where(string.Format("@{0}.Contains({1})", pName, property.Map.MapObjectProperty.PropertyName))
            .SetParameter(pName, ids);
            if (!string.IsNullOrEmpty(remoteQuery.WhereExp))
            {
                query.WhereExp = string.Format("{0} && {1}", query.WhereExp, remoteQuery.WhereExp);
            }
            if (!string.IsNullOrEmpty(query.SelectExp))
            {
                query.SelectExp = string.Format("{0},{1}", property.Map.MapObjectProperty.PropertyName,
                                                query.SelectExp);
            }
            return(query);
        }
示例#2
0
        /// <summary>
        /// 得到延迟的加载条件
        /// </summary>
        /// <param name="infos"></param>
        /// <param name="remoteQuery"></param>
        /// <param name="property"></param>
        /// <returns></returns>
        protected virtual IList <EntityInfo> GetRemoteInfos(IEnumerable <EntityInfo> infos, RemoteQueryInfo remoteQuery,
                                                            OrmPropertyInfo property)
        {
            var query       = GetRemoteQuery(infos, remoteQuery, property);
            var remoteInfos = GetInfos <IList <EntityInfo> >(property.Map.GetMapObject(), query, null);

            return(remoteInfos);
        }