/// <summary> /// Pesquisa a projeção para as informações da entidade. /// </summary> /// <param name="entityInfo"></param> /// <returns></returns> public Query.ProjectionSearcherResult Search(Query.EntityInfo entityInfo) { if (entityInfo != null) { var typeMetadata = _typeSchema.GetTypeMetadata(entityInfo.FullName); if (typeMetadata != null) { var entries = typeMetadata.Where(f => f.Direction == Data.Schema.DirectionParameter.Input || f.Direction == Data.Schema.DirectionParameter.InputOutput).Select(f => new Colosoft.Query.ProjectionSearcherResult.Entry(f.Name, null)); if (typeMetadata.IsVersioned) { entries = entries.Concat(new Colosoft.Query.ProjectionSearcherResult.Entry[] { new Query.ProjectionSearcherResult.Entry(Query.DataAccessConstants.RowVersionPropertyName, null) }); } return(new Query.ProjectionSearcherResult(entries)); } } return(null); }
/// <summary> /// Recupera o origem de dados associada com as informações da entidade informada. /// </summary> /// <param name="entityInfo"></param> /// <returns></returns> protected virtual Colosoft.Query.IQueryDataSource GetDataSource(Query.EntityInfo entityInfo) { Colosoft.Query.IQueryDataSource dataSource = null; if (string.IsNullOrEmpty(entityInfo.FullName) && entityInfo.SubQuery != null) { return(GetDataSource(entityInfo.SubQuery)); } lock (_objLock) if (_entityDataSource.TryGetValue(entityInfo.FullName, out dataSource)) { return(dataSource); } var typeName = _dataCacheManager.Value.Where(f => f.FullName == entityInfo.FullName).FirstOrDefault(); if (typeName != null) { if (_dataCacheManager.Value.Cache != null && _dataCacheManager.Value.Cache.IsLoaded) { dataSource = GetCacheDataSource(); } else { return(GetServerDataSource()); } } if (dataSource == null || !dataSource.IsInitialized) { dataSource = GetServerDataSource(); } lock (_objLock) if (!_entityDataSource.ContainsKey(entityInfo.FullName)) { _entityDataSource.Add(entityInfo.FullName, dataSource); } return(dataSource); }