protected override JoinType GetJoinType(IAssociationType type, FetchMode config, string path, string pathAlias, string lhsTable, string[] lhsColumns, bool nullable, int currentDepth, CascadeStyle cascadeStyle) { if (translator.IsJoin(path, pathAlias)) { return(translator.GetJoinType(path, pathAlias)); } if (translator.HasProjection) { return(JoinType.None); } var selectMode = translator.RootCriteria.GetSelectMode(path); switch (selectMode) { case SelectMode.Undefined: return(base.GetJoinType(type, config, path, pathAlias, lhsTable, lhsColumns, nullable, currentDepth, cascadeStyle)); case SelectMode.Fetch: case SelectMode.FetchLazyProperties: case SelectMode.ChildFetch: case SelectMode.JoinOnly: IsDuplicateAssociation(lhsTable, lhsColumns, type); //deliberately ignore return value! return(GetJoinType(nullable, currentDepth)); case SelectMode.Skip: return(JoinType.None); default: throw new ArgumentOutOfRangeException(nameof(selectMode), selectMode.ToString()); } }
public void SetFetchMode(string associationPath, FetchMode mode) { if (!_fetchModeMap.ContainsKey(associationPath)) { _fetchModeMap.Add(associationPath, mode); } }
protected override JoinType GetJoinType(IAssociationType type, FetchMode config, string path, string lhsTable, string[] lhsColumns, bool nullable, int currentDepth, CascadeStyle cascadeStyle) { if (translator.IsJoin(path)) { return translator.GetJoinType(path); } else { if (translator.HasProjection) { return JoinType.None; } else { FetchMode fetchMode = translator.RootCriteria.GetFetchMode(path); if (IsDefaultFetchMode(fetchMode)) { return base.GetJoinType(type, config, path, lhsTable, lhsColumns, nullable, currentDepth, cascadeStyle); } else { if (fetchMode == FetchMode.Join) { IsDuplicateAssociation(lhsTable, lhsColumns, type); //deliberately ignore return value! return GetJoinType(nullable, currentDepth); } else { return JoinType.None; } } } } }
public IdeaDataObject Fetch(int ideaId, FetchMode mode) { IdeaDataObject ideaData = null; using (var context = new IdeaPoolEntities()) { Idea idea = null; var query = context.Ideas .Include(x => x.User) .AsQueryable(); if (mode == FetchMode.Full) { query = query .Include(x => x.Files) .Include(x => x.IdeaStatus) .Include(x => x.IdeasFieldOfWaters) .Include(x => x.IdeasFieldOfWaters.Select(y => y.FieldOfWater)); } idea = query.SingleOrDefault(x => x.Id == ideaId); ideaData = MapIdea(idea, mode); } return(ideaData); }
/// <summary> /// Constructs StandardProperty instances. /// </summary> /// <param name="name">The name by which the property can be referenced within /// its owner.</param> /// <param name="node">The node name to use for XML-based representation of this /// property.</param> /// <param name="type">The Hibernate Type of this property.</param> /// <param name="lazy">Should this property be handled lazily?</param> /// <param name="insertable">Is this property an insertable value?</param> /// <param name="updateable">Is this property an updateable value?</param> /// <param name="insertGenerated">Is this property generated in the database on insert?</param> /// <param name="updateGenerated">Is this property generated in the database on update?</param> /// <param name="nullable">Is this property a nullable value?</param> /// <param name="checkable">Is this property a checkable value?</param> /// <param name="versionable">Is this property a versionable value?</param> /// <param name="cascadeStyle">The cascade style for this property's value.</param> /// <param name="fetchMode">Any fetch mode defined for this property </param> public StandardProperty( String name, String node, IType type, bool lazy, bool insertable, bool updateable, bool insertGenerated, bool updateGenerated, bool nullable, bool checkable, bool versionable, CascadeStyle cascadeStyle, FetchMode? fetchMode) : base(name, node, type) { this.lazy = lazy; this.insertable = insertable; this.updateable = updateable; this.insertGenerated = insertGenerated; this.updateGenerated = updateGenerated; this.nullable = nullable; this.dirtyCheckable = checkable; this.versionable = versionable; this.cascadeStyle = cascadeStyle; this.fetchMode = fetchMode; }
// Call this function to use the file browser public void ShowWindow(string sStartPath, ToDisplay eToDisplay, FetchMode eFetchMode, string sDefaultExtension = "") { _eToDisplay = eToDisplay; _eFetchMode = eFetchMode; _sDefaultExtension = sDefaultExtension; switch (_eFetchMode) { case FetchMode.SelectFile: _tFiltersList.gameObject.SetActive(true); _tFileName.gameObject.SetActive(false); _tOpenButtonLabel.text = "Open"; break; case FetchMode.SelectFolder: _tFiltersList.gameObject.SetActive(false); _tFileName.gameObject.SetActive(false); _tOpenButtonLabel.text = "Select"; break; case FetchMode.SaveFile: _tFiltersList.gameObject.SetActive(false); _tFileName.gameObject.SetActive(true); _tOpenButtonLabel.text = "Save"; break; } FileBrowser_Core.Instance.OpenFolder(sStartPath); _tRoot.SetActive(true); _bIsOpen = true; _sResult = string.Empty; }
public override string ToString() { var sb = new StringBuilder("NotificationFetchResult("); bool __first = true; if (__isset.fetchMode) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("FetchMode: "); FetchMode.ToString(sb); } if (ItemList != null && __isset.itemList) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("ItemList: "); ItemList.ToString(sb); } sb.Append(")"); return(sb.ToString()); }
��������public ICriteria SetFetchMode(string associationPath, FetchMode mode) �������� { ������������fetchModes[associationPath] = mode; ������������return this; �������� }
������������public ICriteria SetFetchMode(string associationPath, FetchMode mode) ������������ { ����������������root.SetFetchMode(StringHelper.Qualify(path, associationPath), mode); ����������������return this; ������������ }
public AgilityFetchClient(string guid, string apiKey, FetchMode fetchMode) { if (_staticHttpClient == null) { _staticHttpClient = new HttpClient(); } if (string.IsNullOrEmpty(guid)) { throw new ArgumentException("Invalid guid provided"); } if (string.IsNullOrEmpty(apiKey)) { throw new ArgumentException("Invalid apiKey provided"); } var suffix = guid.Substring(guid.Length - 2); _httpClient = _staticHttpClient; _apiKey = apiKey; _fetchMode = fetchMode; string typeStr = fetchMode == FetchMode.Live ? "fetch" : "preview"; if (suffix.StartsWith("-") && GlobalCDNConfigurations.TryGetValue(suffix.ToLowerInvariant(), out var config)) { _baseUrl = $"https://api{config}.aglty.io/{typeStr}"; } else { _baseUrl = $"https://{guid}-api.agilitycms.cloud/{typeStr}"; } }
/// <summary> /// Does the mapping, and Hibernate default semantics, specify that /// this association should be fetched by outer joining /// </summary> protected bool IsJoinedFetchEnabledInMapping(FetchMode config, IAssociationType type) { if (!type.IsEntityType && !type.IsCollectionType) { return(false); } else { switch (config) { case FetchMode.Join: return(true); case FetchMode.Select: return(false); case FetchMode.Default: if (type.IsEntityType) { //TODO: look at the owning property and check that it // isn't lazy (by instrumentation) EntityType entityType = (EntityType)type; IEntityPersister persister = factory.GetEntityPersister(entityType.GetAssociatedEntityName()); return(!persister.HasProxy); } else { return(false); } default: throw new ArgumentOutOfRangeException("config", config, "Unknown OJ strategy " + config); } } }
/// <summary> /// Disable outer join fetching if this loader obtains an /// upgrade lock mode /// </summary> protected override bool IsJoinedFetchEnabled(IAssociationType type, FetchMode config, Cascades.CascadeStyle cascadeStyle) { return lockMode.GreaterThan(LockMode.Read) ? false : base.IsJoinedFetchEnabled(type, config, cascadeStyle); }
protected override JoinType GetJoinType( IAssociationType type, OuterJoinFetchStrategy config, string path, string table, string[] foreignKeyColumns, ISessionFactoryImplementor factory) { if (criteria.IsJoin(path)) { return(JoinType.InnerJoin); } else { FetchMode fm = criteria.GetFetchMode(path); //fm==null || - an Enum can't be null if (fm == FetchMode.Default) { return(base.GetJoinType(type, config, path, table, foreignKeyColumns, factory)); } else { return(fm == FetchMode.Eager ? JoinType.LeftOuterJoin : JoinType.None); } } }
/// <summary> /// Specify an association fetching strategy. /// </summary> /// <param name="criteria">criteria instance</param> /// <param name="alias">Lambda expression returning alias reference</param> /// <param name="fetchMode">The Fetch mode.</param> /// <returns>criteria instance</returns> public static DetachedCriteria SetFetchMode(this DetachedCriteria criteria, Expression <Func <object> > alias, FetchMode fetchMode) { string aliasContainer = ExpressionProcessor.FindMemberExpression(alias.Body); return(criteria.SetFetchMode(aliasContainer, fetchMode)); }
private void InitOuterJoinFetchSetting(HbmManyToOne manyToOneMapping, ManyToOne model) { FetchMode fetchStyle = !manyToOneMapping.fetchSpecified ? (!manyToOneMapping.outerjoinSpecified ? FetchMode.Default : GetFetchStyle(manyToOneMapping.outerjoin)) : GetFetchStyle(manyToOneMapping.fetch); model.FetchMode = fetchStyle; }
private IdeaDataObject MapIdea(Idea idea, FetchMode mode) { IdeaDataObject ideaData = null; if (idea != null) { ideaData = new IdeaDataObject { Id = idea.Id, UniqueId = idea.UniqueId, UserId = idea.UserId, User = new UserNameObject { Id = idea.User.Id, FirstName = idea.User.FirstName, LastName = idea.User.LastName }, IsDraft = idea.IsDraft }; if (mode == FetchMode.Full) { ideaData.Title = idea.Title; ideaData.DescriptionHtml = idea.HtmlContent; ideaData.CreateDate = idea.CreatedDate.ToLocalTime(); idea.Files.ToList().ForEach(file => { ideaData.Files.Add(new FileDataObject { ThumbnailBase64 = Convert.ToBase64String(file.Thumbnail), ContentType = file.ContentType, Id = file.Id, Name = file.Name, SizeInKb = file.SizeInKb, IsUploadedViaDiscussions = file.IsUploadedViaDiscussions }); }); idea.IdeasFieldOfWaters.ToList().ForEach(fieldofWater => { ideaData.FieldOfWater.Add(new FieldOfWaterDataObject { Name = fieldofWater.FieldOfWater.Name, Description = fieldofWater.Description, Id = fieldofWater.FieldOfWater.Id }); }); ideaData.Status = new IdeaStatusDataObject { Id = idea.IdeaStatus.Id, Name = idea.IdeaStatus.Status, Color = idea.IdeaStatus.Color, IsInSubmittedStatus = idea.IdeaStatus.Key == IdeaStatusKeys.SUBMITTED }; } } return(ideaData); }
/// <summary> /// Get the join type (inner, outer, etc) or -1 if the /// association should not be joined. Override on /// subclasses. /// </summary> protected virtual JoinType GetJoinType(IAssociationType type, FetchMode config, string path, string pathAlias, string lhsTable, string[] lhsColumns, bool nullable, int currentDepth, CascadeStyle cascadeStyle) { // 6.0 TODO: inline the call #pragma warning disable 618 return(GetJoinType(type, config, path, lhsTable, lhsColumns, nullable, currentDepth, cascadeStyle)); #pragma warning restore 618 }
private async Task <BotResponseModel> Calculate() { GoldValue responseGold; NasdaqValue responseNasdaq; FetchMode mode = (FetchMode)Enum.Parse(typeof(FetchMode), fetchMode); switch (mode) { case FetchMode.alphavantage: responseGold = await AlphaVantage_Gold(); responseNasdaq = await AlphaVantage_Nasdaq(); break; case FetchMode.investing: responseGold = await InvestingGold(); responseNasdaq = await InvestingNasdaq(); break; default: return(null); } decimal NasPercent = (responseNasdaq.Open * 100) / responseNasdaq.Close; decimal GoldPercent = (NasPercent * 0.4996M) / 100; decimal Pip = (responseGold.Price * GoldPercent) / 100; decimal Sl = 0; decimal A = 0; if (responseNasdaq.Open > responseNasdaq.Close) { A = responseGold.Price + Pip; Sl = responseGold.Price - Pip; } else { A = responseGold.Price - Pip; Sl = responseGold.Price + Pip; } BotResponseModel jsonResult = new BotResponseModel() { Pip = Pip, Sl = Sl, Tp = A, NasdaqPercent = NasPercent, GoldPercent = GoldPercent, Gold_Price = responseGold.Price, Nasdaq_Open = responseNasdaq.Open, Nasdaq_Close = responseNasdaq.Close }; return(jsonResult); }
public IdeaDataObject Fetch(int ideaId, FetchMode mode) { IdeaDataObject idea = ideaData.Fetch(ideaId, mode); if (idea == null) { throw new CustomException("Unable to fetch Idea details."); } return(idea); }
/// <summary> /// Initializes a new instance of <see cref="OpenWeatherMapCache"/>. /// </summary> /// <param name="apiKey">The unique API key obtained from OpenWeatherMap.</param> /// <param name="apiCachePeriod">The number of milliseconds to cache for.</param> /// <param name="fetchMode">The mode of operation. Defaults to <see cref="FetchMode.AlwaysUseLastMeasuredButExtendCache"/>.</param> /// <param name="resiliencyPeriod">The number of milliseconds to keep on using cache values if API is unavailable. Defaults to <see cref="OpenWeatherMapCacheDefaults.DefaultResiliencyPeriod"/>.</param> /// <param name="timeout">The number of milliseconds for the <see cref="WebRequest"/> timeout. Defaults to <see cref="OpenWeatherMapCacheDefaults.DefaultTimeout"/>.</param> /// <param name="logPath">Logs the latest result for a given location to file. Defaults to null (disabled).</param> public OpenWeatherMapCache(string apiKey, int apiCachePeriod, FetchMode fetchMode = FetchMode.AlwaysUseLastMeasuredButExtendCache, int resiliencyPeriod = OpenWeatherMapCacheDefaults.DefaultResiliencyPeriod, int timeout = OpenWeatherMapCacheDefaults.DefaultTimeout, string logPath = null) { _apiKey = apiKey; _apiCachePeriod = apiCachePeriod; _fetchMode = fetchMode; _resiliencyPeriod = resiliencyPeriod; _timeout = timeout; _logPath = logPath; _memoryCache = new MemoryCache(new MemoryCacheOptions()); _asyncKeyedLocker = new AsyncKeyedLocker(); }
protected AgilityRequestBuilder( string apiKey, string guid, FetchMode fetchMode = FetchMode.Live, string baseUrl = null) { _apiKey = apiKey; _guid = guid; _fetchMode = fetchMode; _base_url = TrySanitizeBaseUrl(baseUrl, out string url) ? url : DefaultBaseUrl; }
public AgilityContentListRequestBuilder( string apiKey, string guid, FetchMode fetchMode = FetchMode.Live, string baseUrl = null) : base(apiKey, guid, fetchMode, baseUrl) { Skip = 0; Take = 10; ContentLinkDepth = 1; EncodedFilter = string.Empty; }
/// <summary> /// We can use an inner join for first many-to-many association /// </summary> protected JoinType GetJoinType(IAssociationType type, FetchMode config, String path, ISet visitedAssociations, string lhsTable, string[] lhsColumns, bool nullable, int currentDepth) { JoinType joinType = base.GetJoinType(type, config, path, lhsTable, lhsColumns, nullable, currentDepth, null); //we can use an inner join for the many-to-many if (joinType == JoinType.LeftOuterJoin && string.Empty.Equals(path)) { joinType = JoinType.InnerJoin; } return joinType; }
private void InitOuterJoinFetchSetting(ICollectionPropertiesMapping collectionMapping, Mapping.Collection model) { FetchMode fetchStyle = FetchMode.Default; if (!collectionMapping.FetchMode.HasValue) { if (collectionMapping.OuterJoin.HasValue) { // use old (HB 2.1) defaults if outer-join is specified switch (collectionMapping.OuterJoin.Value) { case HbmOuterJoinStrategy.Auto: fetchStyle = FetchMode.Default; break; case HbmOuterJoinStrategy.True: fetchStyle = FetchMode.Join; break; case HbmOuterJoinStrategy.False: fetchStyle = FetchMode.Select; break; default: throw new ArgumentOutOfRangeException(); } } } else { switch (collectionMapping.FetchMode.Value) { case HbmCollectionFetchMode.Select: fetchStyle = FetchMode.Select; break; case HbmCollectionFetchMode.Join: fetchStyle = FetchMode.Join; break; case HbmCollectionFetchMode.Subselect: fetchStyle = FetchMode.Select; model.IsSubselectLoadable = true; model.Owner.HasSubselectLoadableCollections = true; break; default: throw new ArgumentOutOfRangeException(); } } model.FetchMode = fetchStyle; }
/// <summary> /// We can use an inner join for first many-to-many association /// </summary> protected JoinType GetJoinType(IAssociationType type, FetchMode config, String path, ISet visitedAssociations, string lhsTable, string[] lhsColumns, bool nullable, int currentDepth) { JoinType joinType = base.GetJoinType(type, config, path, lhsTable, lhsColumns, nullable, currentDepth, null); //we can use an inner join for the many-to-many if (joinType == JoinType.LeftOuterJoin && string.Empty.Equals(path)) { joinType = JoinType.InnerJoin; } return(joinType); }
public ComponentType(System.Type componentClass, string[] propertyNames, IGetter[] propertyGetters, ISetter[] propertySetters, // currently not used, see the comment near the end of the method body bool foundCustomAcessor, IType[] propertyTypes, bool[] nullabilities, FetchMode[] joinedFetch, Cascades.CascadeStyle[] cascade, string parentProperty) { this.componentClass = componentClass; this.propertyTypes = propertyTypes; this.propertyNullability = nullabilities; propertySpan = propertyNames.Length; getters = propertyGetters; setters = propertySetters; string[] getterNames = new string[propertySpan]; string[] setterNames = new string[propertySpan]; System.Type[] propTypes = new System.Type[propertySpan]; for (int i = 0; i < propertySpan; i++) { getterNames[i] = getters[i].PropertyName; setterNames[i] = setters[i].PropertyName; propTypes[i] = getters[i].ReturnType; } if (parentProperty == null) { parentSetter = null; parentGetter = null; } else { IPropertyAccessor pa = PropertyAccessorFactory.GetPropertyAccessor(null); parentSetter = pa.GetSetter(componentClass, parentProperty); parentGetter = pa.GetGetter(componentClass, parentProperty); } this.propertyNames = propertyNames; this.cascade = cascade; this.joinedFetch = joinedFetch; if (Environment.UseReflectionOptimizer) { // NH: reflection optimizer works with custom accessors this.optimizer = Environment.BytecodeProvider.GetReflectionOptimizer(componentClass, getters, setters); } }
public DynamicComponentType( string[] propertyNames, IType[] propertyTypes, bool[] nullabilities, FetchMode[] joinedFetch, Cascades.CascadeStyle[] cascade ) { this.propertyNames = propertyNames; this.propertyTypes = propertyTypes; this.propertyNullability = nullabilities; this.joinedFetch = joinedFetch; this.cascade = cascade; propertySpan = propertyTypes.Length; }
public IDataWriter GetDataWriter(FetchMode fetchMode) { IDataWriter dataWriter = null; switch (fetchMode) { case FetchMode.Sql: dataWriter = new SqlDataWriter(); break; case FetchMode.Xml: dataWriter = new XmlDataWriter(); break; } return dataWriter; }
/// <summary> /// To use multi criteria to eagerly load multiple child collection, if the first detached criteria has child collection to query, /// then must use .SetResultTransformer(new DistinctRootEntityResultTransformer() for the first detached criteria /// </summary> /// <typeparam name="TRoot">The type of the root.</typeparam> /// <param name="multiCriteria">The multi criteria.</param> /// <param name="rootCriterion">The root criterion.</param> /// <param name="associationPropertyExpression">The association property expression.</param> /// <param name="fetchMode">The fetch mode.</param> /// <param name="orders">The orders.</param> /// <param name="returnDistinctRoot">If set to <c>true</c> [return distinct root].</param> /// <returns>A <see cref="IMultiCriteria"/></returns> public static IMultiCriteria AddDetachedCriteriaForChild <TRoot> ( this IMultiCriteria multiCriteria, ICriterion rootCriterion, Expression <Func <TRoot, object> > associationPropertyExpression, FetchMode fetchMode, IEnumerable <Order> orders = null, bool returnDistinctRoot = false) { var detachedCriteria = DetachedCriteriaUtil.CreateDetachedCriteriaForChild( rootCriterion, associationPropertyExpression, fetchMode); return(multiCriteria.AddDetachedCriteria(detachedCriteria, orders, returnDistinctRoot)); }
public List <PontoDia> findPontosNoIntervalo(Funcionario funcionario, DateTime inicio, DateTime fim, bool lazyLoadTrabalho = true, bool lazyLoadFolga = true) { FetchMode fetchDiaTrabalho = lazyLoadTrabalho ? FetchMode.Lazy : FetchMode.Eager; FetchMode fetchDiaFolga = lazyLoadFolga ? FetchMode.Lazy : FetchMode.Eager; return (Session .CreateCriteria <PontoDia>() .SetFetchMode("DiaTrabalho", fetchDiaTrabalho) .SetFetchMode("Intervalos", fetchDiaTrabalho) .SetFetchMode("Feriado", fetchDiaTrabalho) .SetFetchMode("DiaFolga", fetchDiaFolga) .Add(Restrictions.Eq("Funcionario", funcionario)) .Add(Restrictions.Between("Data", inicio, fim)) .List <PontoDia>().ToList()); }
public override int GetHashCode() { int hashcode = 157; unchecked { if (__isset.fetchMode) { hashcode = (hashcode * 397) + FetchMode.GetHashCode(); } if (__isset.itemList) { hashcode = (hashcode * 397) + TCollections.GetHashCode(ItemList); } } return(hashcode); }
private SelectMode GetSelectMode(FetchMode mode) { switch (mode) { case FetchMode.Default: return(SelectMode.Undefined); case FetchMode.Select: return(SelectMode.Skip); case FetchMode.Join: return(SelectMode.Fetch); default: throw new ArgumentOutOfRangeException(nameof(mode), mode, null); } }
public ICriteria SetFetchMode(string associationPath, FetchMode fetchMode) { ICriteriaEvent criteriaEvent = new SetFetchModeEvent(associationPath, fetchMode); foreach (IShard shard in shards) { if (shard.GetCriteriaById(criteriaId) != null) { shard.GetCriteriaById(criteriaId).SetFetchMode(associationPath, fetchMode); } else { shard.AddCriteriaEvent(criteriaId, criteriaEvent); } } return(this); }
public ICriteria SetFetchMode(string associationPath, FetchMode fetchMode) { ICriteriaEvent criteriaEvent = new SetFetchModeEvent(associationPath, fetchMode); foreach (IShard shard in shards) { if (shardToCriteriaMap[shard] != null) { shardToCriteriaMap[shard].SetFetchMode(associationPath, fetchMode); } else { shardToEventListMap[shard].Add(criteriaEvent); } } return(this); }
TEntity IRepository <TEntity> .Get(string projectionName, object entityId, FetchMode fetchMode) { TEntity entity = null; if (fetchMode == FetchMode.UseIdentityMap && (entity = this.DataService.IdentityMap.Get <TEntity>(projectionName, entityId)) != null) { return(entity); } string primaryKeyFieldName = typeof(TEntity).GetPrimaryKeyFieldName(); entity = this.Query(projectionName).Get(primaryKeyFieldName, entityId); if (entity != null) { this.DataService.IdentityMap.Put(projectionName, entity); } return(entity); }
public IDataReader GetdataReader(FetchMode dataFetchMode) { IDataReader dataReader = null; //var dataFetchType = (FetchType)Enum.Parse(typeof(FetchType), dataFetchMode); var dataFetchType = dataFetchMode; switch (dataFetchType) { case FetchMode.Sql: dataReader = new SqlDataReader(); break; case FetchMode.Xml: dataReader = new XmlDataReader(); break; } return dataReader; }
public OperationResult <TModel> Update(TUpdateModel model, FetchMode fetchMode = FetchMode.Simple) { var item = All(fetchMode).SingleOrDefault(x => x.Id == model.Id); Mapper.Map(model, item); var result = OperationResult.CreateResult <TModel>(); try { Context.SaveChanges(); result.Result = item; } catch (Exception exception) { LogService.LogError(exception); result.Error = exception; result.AddError(ExceptionHelper.GetMessages(exception)); } return(result); }
/// <summary> /// Creates the final fetching strategy with the provided <see cref="FetchMode" />. /// </summary> /// <param name="mode"> /// The <see cref="FetchMode" /> value to use for the built fetching strategy. /// </param> /// <returns> /// The <see cref="T:TQuery"/> query this <see cref="FetchBuilder{TQuery}" /> was created with. /// </returns> /// <exception cref="InvalidOperationException"> /// The alias (<see cref="_alias" />) is already used for another fetching strategy. /// </exception> protected virtual TQuery With(FetchMode mode) { bool exists = _implementor.Fetches.Any(x => x.Path == _path && x.Alias == _alias); if (exists) { return(_query); } bool aliasUsed = _implementor.Fetches.Any(x => x.HasAlias && x.Alias == _alias); if (aliasUsed) { throw new InvalidOperationException("The alias provided for the fetching strategy is already used."); } string[] steps = _path.Split('.'); string path = string.Empty; for (int i = 0; i < steps.Length - 1; i++) { if (i > 0) { path += "."; } path += steps[i]; bool pathExists = _implementor.Fetches .Any(x => x.Path == path); if (!pathExists) { _implementor.Fetches.Add(new Fetch(path, path, mode)); } } _implementor.Fetches.Add(new Fetch(_path, _alias, mode)); return(_query); }
public AbstractCollectionPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory) { this.factory = factory; dialect = factory.Dialect; this.cache = cache; //sqlExceptionConverter = factory.SQLExceptionConverter; collectionType = collection.CollectionType; role = collection.Role; ownerClass = collection.OwnerClass; ownerPersister = factory.GetEntityPersister(ownerClass); queryLoaderName = collection.LoaderName; Alias alias = new Alias("__"); sqlOrderByString = collection.OrderBy; hasOrder = sqlOrderByString != null; sqlOrderByStringTemplate = hasOrder ? Template.RenderOrderByStringTemplate(sqlOrderByString, dialect, factory.SQLFunctionRegistry) : null; sqlWhereString = collection.Where; hasWhere = sqlWhereString != null; sqlWhereStringTemplate = hasWhere ? Template.RenderWhereStringTemplate(sqlWhereString, dialect, factory.SQLFunctionRegistry) : null; hasOrphanDelete = collection.OrphanDelete; batchSize = collection.BatchSize; isVersioned = collection.IsOptimisticLocked; keyType = collection.Key.Type; int keySpan = collection.Key.ColumnSpan; keyColumnNames = new string[keySpan]; string[] keyAliases = new string[keySpan]; int k = 0; foreach (Column col in collection.Key.ColumnCollection) { keyColumnNames[k] = col.GetQuotedName(dialect); keyAliases[k] = col.GetAlias(dialect); k++; } keyColumnAliases = alias.ToAliasStrings(keyAliases, dialect); //unquotedKeyColumnNames = StringHelper.Unquote( keyColumnAliases ); ISet distinctColumns = new HashedSet(); CheckColumnDuplication(distinctColumns, collection.Key.ColumnCollection); //isSet = collection.IsSet; //isSorted = collection.IsSorted; primitiveArray = collection.IsPrimitiveArray; array = collection.IsArray; subselectLoadable = collection.IsSubselectLoadable; IValue element = collection.Element; int elementSpan = element.ColumnSpan; Table table = collection.CollectionTable; fetchMode = element.FetchMode; elementType = element.Type; if (!collection.IsOneToMany) { CheckColumnDuplication(distinctColumns, element.ColumnCollection); } if (elementType.IsEntityType) { elementPersister = factory.GetEntityPersister(((EntityType) elementType).AssociatedClass); } else { elementPersister = null; } qualifiedTableName = table.GetQualifiedName(dialect, factory.DefaultSchema); elementColumnAliases = new string[elementSpan]; elementColumnNames = new string[elementSpan]; elementFormulaTemplates = new string[elementSpan]; elementFormulas = new string[elementSpan]; elementColumnIsSettable = new bool[elementSpan]; elementColumnIsInPrimaryKey = new bool[elementSpan]; int j = 0; foreach (ISelectable selectable in element.ColumnCollection) { elementColumnAliases[j] = selectable.GetAlias(dialect); if (selectable.IsFormula) { Formula form = (Formula) selectable; elementFormulaTemplates[j] = form.GetTemplate(dialect, factory.SQLFunctionRegistry); elementFormulas[j] = form.FormulaString; } else { Column col = (Column) selectable; elementColumnNames[j] = col.GetQuotedName(dialect); elementColumnIsSettable[j] = true; elementColumnIsInPrimaryKey[j] = !col.IsNullable; } j++; } hasIndex = collection.IsIndexed; if (hasIndex) { IndexedCollection indexedCollection = (IndexedCollection) collection; indexType = indexedCollection.Index.Type; int indexSpan = indexedCollection.Index.ColumnSpan; indexColumnNames = new string[indexSpan]; string[] indexAliases = new string[indexSpan]; int i = 0; foreach (Column indexCol in indexedCollection.Index.ColumnCollection) { indexAliases[i] = indexCol.GetAlias(dialect); indexColumnNames[i] = indexCol.GetQuotedName(dialect); i++; } indexColumnAliases = alias.ToAliasStrings(indexAliases, dialect); CheckColumnDuplication(distinctColumns, indexedCollection.Index.ColumnCollection); } else { indexType = null; indexColumnNames = null; indexColumnAliases = null; } hasIdentifier = collection.IsIdentified; if (hasIdentifier) { if (collection.IsOneToMany) { throw new MappingException("one-to-many collections with identifiers are not supported."); } IdentifierCollection idColl = (IdentifierCollection) collection; identifierType = idColl.Identifier.Type; Column col = null; foreach (Column column in idColl.Identifier.ColumnCollection) { col = column; break; } identifierColumnName = col.GetQuotedName(dialect); identifierColumnAlias = alias.ToAliasString(col.GetAlias(dialect), dialect); identifierGenerator = idColl.Identifier.CreateIdentifierGenerator(dialect); CheckColumnDuplication(distinctColumns, idColl.Identifier.ColumnCollection); } else { identifierType = null; identifierColumnName = null; identifierColumnAlias = null; identifierGenerator = null; } sqlInsertRowString = GenerateInsertRowString(); if (collection.CustomSQLInsert == null) { insertCallable = false; insertCheckStyle = ExecuteUpdateResultCheckStyle.Count; } else { sqlInsertRowString = new SqlCommandInfo(collection.CustomSQLInsert, sqlInsertRowString.ParameterTypes); insertCallable = collection.IsCustomInsertCallable; insertCheckStyle = collection.CustomSQLInsertCheckStyle == null ? ExecuteUpdateResultCheckStyle.DetermineDefault(collection.CustomSQLInsert, insertCallable) : collection.CustomSQLInsertCheckStyle; } sqlUpdateRowString = GenerateUpdateRowString(); if (collection.CustomSQLUpdate == null) { updateCallable = false; updateCheckStyle = ExecuteUpdateResultCheckStyle.Count; } else { sqlUpdateRowString = new SqlCommandInfo(collection.CustomSQLUpdate, sqlUpdateRowString.ParameterTypes); updateCallable = collection.IsCustomUpdateCallable; updateCheckStyle = collection.CustomSQLUpdateCheckStyle == null ? ExecuteUpdateResultCheckStyle.DetermineDefault(collection.CustomSQLUpdate, updateCallable) : collection.CustomSQLUpdateCheckStyle; } sqlDeleteRowString = GenerateDeleteRowString(); if (collection.CustomSQLDelete == null) { deleteCallable = false; deleteCheckStyle = ExecuteUpdateResultCheckStyle.None; } else { sqlDeleteRowString = new SqlCommandInfo(collection.CustomSQLDelete, sqlDeleteRowString.ParameterTypes); deleteCallable = collection.IsCustomDeleteCallable; deleteCheckStyle = ExecuteUpdateResultCheckStyle.None; } sqlDeleteString = GenerateDeleteString(); if (collection.CustomSQLDeleteAll == null) { deleteAllCallable = false; deleteAllCheckStyle = ExecuteUpdateResultCheckStyle.None; } else { sqlDeleteString = new SqlCommandInfo(collection.CustomSQLDeleteAll, sqlDeleteString.ParameterTypes); deleteAllCallable = collection.IsCustomDeleteAllCallable; deleteAllCheckStyle = ExecuteUpdateResultCheckStyle.None; } isLazy = collection.IsLazy; isInverse = collection.IsInverse; if (collection.IsArray) { elementClass = ((Array) collection).ElementClass; } else { // for non-arrays, we don't need to know the element class elementClass = null; } if (elementType.IsComponentType) { elementPropertyMapping = new CompositeElementPropertyMapping( elementColumnNames, elementFormulaTemplates, (IAbstractComponentType) elementType, factory); } else if (!elementType.IsEntityType) { elementPropertyMapping = new ElementPropertyMapping(elementColumnNames, elementType); } else { IEntityPersister persister = factory.GetEntityPersister(((EntityType) elementType).AssociatedClass); // Not all classpersisters implement IPropertyMapping! if (persister is IPropertyMapping) { elementPropertyMapping = (IPropertyMapping) persister; } else { elementPropertyMapping = new ElementPropertyMapping(elementColumnNames, elementType); } } // Handle any filters applied to this collection filterHelper = new FilterHelper(collection.FilterMap, dialect, factory.SQLFunctionRegistry); // Handle any filters applied to this collection for many-to-many manyToManyFilterHelper = new FilterHelper(collection.ManyToManyFilterMap, dialect, factory.SQLFunctionRegistry); manyToManyWhereString = StringHelper.IsNotEmpty(collection.ManyToManyWhere) ? "( " + collection.ManyToManyWhere + " )" : null; manyToManyWhereTemplate = manyToManyWhereString == null ? null : Template.RenderWhereStringTemplate(manyToManyWhereString, factory.Dialect, factory.SQLFunctionRegistry); // , factory.getSqlFunctionRegistry() ); manyToManyOrderByString = collection.ManyToManyOrdering; manyToManyOrderByTemplate = manyToManyOrderByString == null ? null : Template.RenderOrderByStringTemplate(manyToManyOrderByString, factory.Dialect, factory.SQLFunctionRegistry); // , factory.getSqlFunctionRegistry() ); InitCollectionPropertyMap(); }
private void DeferredFetchAndUpdateCareer(FetchMode online) { ZTnTrace.Trace(MethodBase.GetCurrentMethod()); ProgressDialog progressDialog = null; if (online == FetchMode.Online) { progressDialog = ProgressDialog.Show(Activity, Resources.GetString(Resource.String.LoadingCareer), Resources.GetString(Resource.String.WaitWhileRetrievingData), true); } new Thread(() => { try { FetchCareer(online); Activity.RunOnUiThread(() => { if (online == FetchMode.Online) { Debug.Assert(progressDialog != null, "progressDialog != null"); progressDialog.Dismiss(); } UpdateCareerView(); }); } catch (FileNotInCacheException) { if (Activity != null) { Activity.RunOnUiThread(() => { if (online == FetchMode.Online) { progressDialog.Dismiss(); } Toast.MakeText(Activity, "Career not in cache" + Environment.NewLine + "Please use refresh action", ToastLength.Long) .Show(); }); } } catch (Exception exception) { Debug.WriteLine("An exception occured in activity {0}: {1}", Activity, exception); if (Activity != null) { Activity.RunOnUiThread(() => { if (online == FetchMode.Online) { progressDialog.Dismiss(); } Toast.MakeText(Activity, Resources.GetString(Resource.String.ErrorOccuredWhileRetrievingData), ToastLength.Long) .Show(); }); } } }).Start(); }
private static bool IsDefaultFetchMode(FetchMode fetchMode) { return fetchMode == FetchMode.Default; }
private void FetchCareer(FetchMode online) { ZTnTrace.Trace(MethodBase.GetCurrentMethod()); D3Api.Host = host; var dataProvider = (DataProviders.CacheableDataProvider)D3Api.DataProvider; dataProvider.FetchMode = online; try { career = Career.CreateFromBattleTag(new BattleTag(battleTag)); } catch (Exception exception) { Console.WriteLine(exception); career = null; throw; } finally { dataProvider.FetchMode = D3Context.Instance.FetchMode; } }
private static IconsContainer FetchIcons(FetchMode online) { ZTnTrace.Trace(MethodBase.GetCurrentMethod()); var icons = new IconsContainer(); var dataProvider = (CacheableDataProvider)D3Api.DataProvider; dataProvider.FetchMode = online; try { icons.FetchItemIcons(D3Context.Instance.CurrentHero.Items); icons.FetchActiveSkillIcons(D3Context.Instance.CurrentHero.Skills.Active); icons.FetchPassiveSkillIcons(D3Context.Instance.CurrentHero.Skills.Passive); icons.FetchLegendaryPowerIcons(D3Context.Instance.CurrentHero.LegendaryPowers); } catch (Exception exception) { Console.WriteLine(exception); D3Context.Instance.Icons = null; throw; } finally { dataProvider.FetchMode = D3Context.Instance.FetchMode; } return icons; }
/// <summary> /// The superclass deliberately excludes collections /// </summary> protected override bool IsJoinedFetchEnabled(IAssociationType type, FetchMode config, CascadeStyle cascadeStyle) { return IsJoinedFetchEnabledInMapping(config, type); }
public AbstractCollectionPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache, Configuration cfg, ISessionFactoryImplementor factory) { this.factory = factory; this.cache = cache; if (factory.Settings.IsStructuredCacheEntriesEnabled) { cacheEntryStructure = collection.IsMap ? (ICacheEntryStructure) new StructuredMapCacheEntry() : (ICacheEntryStructure) new StructuredCollectionCacheEntry(); } else { cacheEntryStructure = new UnstructuredCacheEntry(); } dialect = factory.Dialect; sqlExceptionConverter = factory.SQLExceptionConverter; collectionType = collection.CollectionType; role = collection.Role; entityName = collection.OwnerEntityName; ownerPersister = factory.GetEntityPersister(entityName); queryLoaderName = collection.LoaderName; nodeName = collection.NodeName; isMutable = collection.IsMutable; Table table = collection.CollectionTable; fetchMode = collection.Element.FetchMode; elementType = collection.Element.Type; isPrimitiveArray = collection.IsPrimitiveArray; isArray = collection.IsArray; subselectLoadable = collection.IsSubselectLoadable; qualifiedTableName = table.GetQualifiedName(dialect, factory.Settings.DefaultCatalogName, factory.Settings.DefaultSchemaName); int spacesSize = 1 + collection.SynchronizedTables.Count; spaces = new string[spacesSize]; int ispa = 0; spaces[ispa++] = qualifiedTableName; foreach (string s in collection.SynchronizedTables) { spaces[ispa++] = s; } sqlOrderByString = collection.OrderBy; hasOrder = sqlOrderByString != null; sqlOrderByStringTemplate = hasOrder ? Template.RenderOrderByStringTemplate(sqlOrderByString, dialect, factory.SQLFunctionRegistry) : null; sqlWhereString = !string.IsNullOrEmpty(collection.Where) ? '(' + collection.Where + ')' : null; hasWhere = sqlWhereString != null; sqlWhereStringTemplate = hasWhere ? Template.RenderWhereStringTemplate(sqlWhereString, dialect, factory.SQLFunctionRegistry) : null; hasOrphanDelete = collection.HasOrphanDelete; int batch = collection.BatchSize; if (batch == -1) { batch = factory.Settings.DefaultBatchFetchSize; } batchSize = batch; isVersioned = collection.IsOptimisticLocked; keyType = collection.Key.Type; int keySpan = collection.Key.ColumnSpan; keyColumnNames = new string[keySpan]; keyColumnAliases = new string[keySpan]; int k = 0; foreach (Column col in collection.Key.ColumnIterator) { keyColumnNames[k] = col.GetQuotedName(dialect); keyColumnAliases[k] = col.GetAlias(dialect); k++; } ISet distinctColumns = new HashedSet(); CheckColumnDuplication(distinctColumns, collection.Key.ColumnIterator); #region Element IValue element = collection.Element; if (!collection.IsOneToMany) { CheckColumnDuplication(distinctColumns, element.ColumnIterator); } string elemNode = collection.ElementNodeName; if (elementType.IsEntityType) { string _entityName = ((EntityType) elementType).GetAssociatedEntityName(); elementPersister = factory.GetEntityPersister(_entityName); if (elemNode == null) { elemNode = cfg.GetClassMapping(_entityName).NodeName; } // NativeSQL: collect element column and auto-aliases } else { elementPersister = null; } elementNodeName = elemNode; int elementSpan = element.ColumnSpan; elementColumnAliases = new string[elementSpan]; elementColumnNames = new string[elementSpan]; elementFormulaTemplates = new string[elementSpan]; elementFormulas = new string[elementSpan]; elementColumnIsSettable = new bool[elementSpan]; elementColumnIsInPrimaryKey = new bool[elementSpan]; bool isPureFormula = true; bool hasNotNullableColumns = false; int j = 0; foreach (ISelectable selectable in element.ColumnIterator) { elementColumnAliases[j] = selectable.GetAlias(dialect); if (selectable.IsFormula) { Formula form = (Formula) selectable; elementFormulaTemplates[j] = form.GetTemplate(dialect, factory.SQLFunctionRegistry); elementFormulas[j] = form.FormulaString; } else { Column col = (Column) selectable; elementColumnNames[j] = col.GetQuotedName(dialect); elementColumnIsSettable[j] = true; elementColumnIsInPrimaryKey[j] = !col.IsNullable; if (!col.IsNullable) { hasNotNullableColumns = true; } isPureFormula = false; } j++; } elementIsPureFormula = isPureFormula; //workaround, for backward compatibility of sets with no //not-null columns, assume all columns are used in the //row locator SQL if (!hasNotNullableColumns) { ArrayHelper.Fill(elementColumnIsInPrimaryKey, true); } #endregion #region INDEX AND ROW SELECT hasIndex = collection.IsIndexed; if (hasIndex) { // NativeSQL: collect index column and auto-aliases IndexedCollection indexedCollection = (IndexedCollection) collection; indexType = indexedCollection.Index.Type; int indexSpan = indexedCollection.Index.ColumnSpan; indexColumnNames = new string[indexSpan]; indexFormulaTemplates = new string[indexSpan]; indexFormulas = new string[indexSpan]; indexColumnIsSettable = new bool[indexSpan]; indexColumnAliases = new string[indexSpan]; bool hasFormula = false; int i = 0; foreach (ISelectable selectable in indexedCollection.Index.ColumnIterator) { indexColumnAliases[i] = selectable.GetAlias(dialect); if (selectable.IsFormula) { Formula indexForm = (Formula) selectable; indexFormulaTemplates[i] = indexForm.GetTemplate(dialect, factory.SQLFunctionRegistry); indexFormulas[i] = indexForm.FormulaString; hasFormula = true; } else { Column indexCol = (Column) selectable; indexColumnNames[i] = indexCol.GetQuotedName(dialect); indexColumnIsSettable[i] = true; } i++; } indexContainsFormula = hasFormula; baseIndex = indexedCollection.IsList ? ((List) indexedCollection).BaseIndex : 0; indexNodeName = indexedCollection.IndexNodeName; CheckColumnDuplication(distinctColumns, indexedCollection.Index.ColumnIterator); } else { indexContainsFormula = false; indexColumnIsSettable = null; indexFormulaTemplates = null; indexFormulas = null; indexType = null; indexColumnNames = null; indexColumnAliases = null; baseIndex = 0; indexNodeName = null; } hasIdentifier = collection.IsIdentified; if (hasIdentifier) { if (collection.IsOneToMany) { throw new MappingException("one-to-many collections with identifiers are not supported."); } IdentifierCollection idColl = (IdentifierCollection) collection; identifierType = idColl.Identifier.Type; Column col = null; foreach (Column column in idColl.Identifier.ColumnIterator) { col = column; break; } identifierColumnName = col.GetQuotedName(dialect); identifierColumnAlias = col.GetAlias(dialect); identifierGenerator = idColl.Identifier.CreateIdentifierGenerator(factory.Dialect, factory.Settings.DefaultCatalogName, factory.Settings.DefaultSchemaName, null); // NH see : identityDelegate declaration IPostInsertIdentifierGenerator pig = (identifierGenerator as IPostInsertIdentifierGenerator); if (pig != null) { identityDelegate = pig.GetInsertGeneratedIdentifierDelegate(this, Factory, UseGetGeneratedKeys()); } else { identityDelegate = null; } CheckColumnDuplication(distinctColumns, idColl.Identifier.ColumnIterator); } else { identifierType = null; identifierColumnName = null; identifierColumnAlias = null; identifierGenerator = null; identityDelegate = null; } #endregion #region GENERATE THE SQL // NH Different behavior : for the Insert SQL we are managing isPostInsertIdentifier (not supported in H3.2.5) if (collection.CustomSQLInsert == null) { if (!IsIdentifierAssignedByInsert) { sqlInsertRowString = GenerateInsertRowString(); } else { sqlInsertRowString = GenerateIdentityInsertRowString(); } insertCallable = false; insertCheckStyle = ExecuteUpdateResultCheckStyle.Count; } else { SqlType[] parmsTypes = GenerateInsertRowString().ParameterTypes; sqlInsertRowString = new SqlCommandInfo(collection.CustomSQLInsert, parmsTypes); insertCallable = collection.IsCustomInsertCallable; insertCheckStyle = collection.CustomSQLInsertCheckStyle ?? ExecuteUpdateResultCheckStyle.DetermineDefault(collection.CustomSQLInsert, insertCallable); } sqlUpdateRowString = GenerateUpdateRowString(); if (collection.CustomSQLUpdate == null) { updateCallable = false; updateCheckStyle = ExecuteUpdateResultCheckStyle.Count; } else { sqlUpdateRowString = new SqlCommandInfo(collection.CustomSQLUpdate, sqlUpdateRowString.ParameterTypes); updateCallable = collection.IsCustomUpdateCallable; updateCheckStyle = collection.CustomSQLUpdateCheckStyle ?? ExecuteUpdateResultCheckStyle.DetermineDefault(collection.CustomSQLUpdate, updateCallable); } sqlDeleteRowString = GenerateDeleteRowString(); if (collection.CustomSQLDelete == null) { deleteCallable = false; deleteCheckStyle = ExecuteUpdateResultCheckStyle.None; } else { sqlDeleteRowString = new SqlCommandInfo(collection.CustomSQLDelete, sqlDeleteRowString.ParameterTypes); deleteCallable = collection.IsCustomDeleteCallable; deleteCheckStyle = ExecuteUpdateResultCheckStyle.None; } sqlDeleteString = GenerateDeleteString(); if (collection.CustomSQLDeleteAll == null) { deleteAllCallable = false; deleteAllCheckStyle = ExecuteUpdateResultCheckStyle.None; } else { sqlDeleteString = new SqlCommandInfo(collection.CustomSQLDeleteAll, sqlDeleteString.ParameterTypes); deleteAllCallable = collection.IsCustomDeleteAllCallable; deleteAllCheckStyle = ExecuteUpdateResultCheckStyle.None; } isCollectionIntegerIndex = collection.IsIndexed && !collection.IsMap; sqlDetectRowByIndexString = GenerateDetectRowByIndexString(); sqlDetectRowByElementString = GenerateDetectRowByElementString(); sqlSelectRowByIndexString = GenerateSelectRowByIndexString(); LogStaticSQL(); #endregion isLazy = collection.IsLazy; isExtraLazy = collection.ExtraLazy; isInverse = collection.IsInverse; if (collection.IsArray) { elementClass = ((Array) collection).ElementClass; } else { // for non-arrays, we don't need to know the element class elementClass = null; } if (elementType.IsComponentType) { elementPropertyMapping = new CompositeElementPropertyMapping(elementColumnNames, elementFormulaTemplates, (IAbstractComponentType) elementType, factory); } else if (!elementType.IsEntityType) { elementPropertyMapping = new ElementPropertyMapping(elementColumnNames, elementType); } else { elementPropertyMapping = elementPersister as IPropertyMapping; if (elementPropertyMapping == null) { elementPropertyMapping = new ElementPropertyMapping(elementColumnNames, elementType); } } // Handle any filters applied to this collection filterHelper = new FilterHelper(collection.FilterMap, dialect, factory.SQLFunctionRegistry); // Handle any filters applied to this collection for many-to-many manyToManyFilterHelper = new FilterHelper(collection.ManyToManyFilterMap, dialect, factory.SQLFunctionRegistry); manyToManyWhereString = !string.IsNullOrEmpty(collection.ManyToManyWhere) ? "( " + collection.ManyToManyWhere + " )" : null; manyToManyWhereTemplate = manyToManyWhereString == null ? null : Template.RenderWhereStringTemplate(manyToManyWhereString, factory.Dialect, factory.SQLFunctionRegistry); manyToManyOrderByString = collection.ManyToManyOrdering; manyToManyOrderByTemplate = manyToManyOrderByString == null ? null : Template.RenderOrderByStringTemplate(manyToManyOrderByString, factory.Dialect, factory.SQLFunctionRegistry); InitCollectionPropertyMap(); }
public IConfiguration SetDefaultFetchMode(FetchMode value) { if (value != FetchMode.Default) { _defaultFetchMode = value; } return this; }
/// <summary> /// Initializes a new instance of the <see cref="CriteriaFetchMode"/> class. /// </summary> /// <param name="collectionName">Name of the collection.</param> /// <param name="fetchModeType">Type of the fetch mode.</param> public CriteriaFetchMode(string collectionName, FetchMode fetchModeType) { _CollectionName = collectionName; _FetchModeType = fetchModeType; }
private static Hero FetchHero(FetchMode online) { ZTnTrace.Trace(MethodBase.GetCurrentMethod()); Hero hero; D3Api.Host = D3Context.Instance.Host; var dataProvider = (CacheableDataProvider)D3Api.DataProvider; dataProvider.FetchMode = online; try { hero = Hero.CreateFromHeroId(new BattleTag(D3Context.Instance.BattleTag), D3Context.Instance.CurrentHeroSummary.Id); } catch (Exception exception) { Console.WriteLine(exception); hero = null; } finally { dataProvider.FetchMode = D3Context.Instance.FetchMode; } return hero; }
private void DeferredFetchHero(FetchMode online) { ZTnTrace.Trace(MethodBase.GetCurrentMethod()); var progressDialog = ProgressDialog.Show(Activity, Resources.GetString(Resource.String.LoadingHero), Resources.GetString(Resource.String.WaitWhileRetrievingData), true); new Thread(() => { try { D3Context.Instance.CurrentHero = FetchHero(online); Activity.RunOnUiThread(() => progressDialog.SetTitle(Resources.GetString(Resource.String.LoadingItems))); D3Context.Instance.CurrentHeroItems = FetchFullItems(online); Activity.RunOnUiThread(() => progressDialog.SetTitle(Resources.GetString(Resource.String.LoadingIcons))); // Icons are fetched with Online.OnlineIfMissing even if FetchMode.Online is asked var fetchIconsOnlineMode = (online == FetchMode.Online ? FetchMode.OnlineIfMissing : online); D3Context.Instance.Icons = FetchIcons(fetchIconsOnlineMode); Activity.RunOnUiThread(() => { progressDialog.Dismiss(); FragmentCharacteristics.UpdateFragment(); FragmentComputed.UpdateFragment(); FragmentSkills.UpdateFragment(); FragmentGear.UpdateFragment(); }); } catch (FileNotInCacheException) { Activity.RunOnUiThread(() => { progressDialog.Dismiss(); Toast.MakeText(Activity, "Hero not in cache" + Environment.NewLine + "Please use refresh action", ToastLength.Long) .Show(); }); } catch (Exception exception) { Activity.RunOnUiThread(() => { progressDialog.Dismiss(); Toast.MakeText(Activity, Resources.GetString(Resource.String.ErrorOccuredWhileRetrievingData), ToastLength.Long) .Show(); Console.WriteLine(exception); }); } }).Start(); }
private static HeroItems FetchFullItems(FetchMode online) { var heroItems = D3Context.Instance.CurrentHero.Items; var dataProvider = (CacheableDataProvider)D3Api.DataProvider; dataProvider.FetchMode = online; try { // Compute set items bonus heroItems.UpdateToFullItems(); // Compute set items bonus var items = new List<Item> { (Item)heroItems.Bracers, (Item)heroItems.Feet, (Item)heroItems.Hands, (Item)heroItems.Head, (Item)heroItems.LeftFinger, (Item)heroItems.Legs, (Item)heroItems.Neck, (Item)heroItems.RightFinger, (Item)heroItems.Shoulders, (Item)heroItems.Torso, (Item)heroItems.Waist, (Item)heroItems.MainHand, (Item)heroItems.OffHand }; items = items.Where(i => i != null) .ToList(); D3Context.Instance.ActivatedSetBonus = new Item(items.GetActivatedSetBonus()); D3Context.Instance.ActivatedSets = items.GetActivatedSets(); } catch (Exception exception) { Console.WriteLine(exception); D3Context.Instance.CurrentHeroItems = null; D3Context.Instance.ActivatedSetBonus = null; throw; } finally { dataProvider.FetchMode = D3Context.Instance.FetchMode; } return heroItems; }
/// <summary> /// Does the mapping, and Hibernate default semantics, specify that /// this association should be fetched by outer joining /// </summary> protected bool IsJoinedFetchEnabledInMapping(FetchMode config, IAssociationType type) { if (!type.IsEntityType && !type.IsCollectionType) { return false; } else { switch (config) { case FetchMode.Join: return true; case FetchMode.Select: return false; case FetchMode.Default: if (type.IsEntityType) { //TODO: look at the owning property and check that it // isn't lazy (by instrumentation) EntityType entityType = (EntityType)type; IEntityPersister persister = factory.GetEntityPersister(entityType.GetAssociatedEntityName()); return !persister.HasProxy; } else { return false; } default: throw new ArgumentOutOfRangeException("config", config, "Unknown OJ strategy " + config); } } }
protected override bool IsJoinedFetchEnabled(IAssociationType type, FetchMode config, CascadeStyle cascadeStyle) { return (type.IsEntityType || type.IsCollectionType) && (cascadeStyle == null || cascadeStyle.DoCascade(cascadeAction)); }
/// <summary> /// Get the join type (inner, outer, etc) or -1 if the /// association should not be joined. Override on /// subclasses. /// </summary> protected virtual JoinType GetJoinType(IAssociationType type, FetchMode config, string path, string lhsTable, string[] lhsColumns, bool nullable, int currentDepth, CascadeStyle cascadeStyle) { if (!IsJoinedFetchEnabled(type, config, cascadeStyle)) return JoinType.None; if (IsTooDeep(currentDepth) || (type.IsCollectionType && IsTooManyCollections)) return JoinType.None; bool dupe = IsDuplicateAssociation(lhsTable, lhsColumns, type); if (dupe) return JoinType.None; return GetJoinType(nullable, currentDepth); }
///<summary>Construct a SetFetchModeEvent</summary> /// <param name="associationPath">the association path of the fetch mode /// we'll set on the {@link Criteria} when the event fires.</param> /// <param name="mode">the mode we'll set on the {@link Criteria} when the event fires.</param> public SetFetchModeEvent(string associationPath, FetchMode mode) { this.associationPath = associationPath; this.mode = mode; }
/// <summary> /// Override on subclasses to enable or suppress joining /// of certain association types /// </summary> protected virtual bool IsJoinedFetchEnabled(IAssociationType type, FetchMode config, CascadeStyle cascadeStyle) { return type.IsEntityType && IsJoinedFetchEnabledInMapping(config, type); }
public static void BindComponent(XmlNode node, Component model, System.Type reflectedClass, string className, string path, bool isNullable, Mappings mappings) { XmlAttribute classNode = node.Attributes["class"]; if ("dynamic-component".Equals(node.Name)) { model.IsEmbedded = false; model.IsDynamic = true; } else if (classNode != null) { model.ComponentClass = ClassForNameChecked( classNode.Value, mappings, "component class not found: {0}"); model.IsEmbedded = false; } else if (reflectedClass != null) { model.ComponentClass = reflectedClass; model.IsEmbedded = false; } else { // an "embedded" component (ids only) model.ComponentClass = model.Owner.MappedClass; model.IsEmbedded = true; } foreach (XmlNode subnode in node.ChildNodes) { //I am only concerned with elements that are from the nhibernate namespace if (subnode.NamespaceURI != Configuration.MappingSchemaXMLNS) { continue; } string name = subnode.LocalName; //.Name; string propertyName = GetPropertyName(subnode); string subpath = propertyName == null ? null : StringHelper.Qualify(path, propertyName); CollectionType collectType = CollectionType.CollectionTypeFromString(name); IValue value = null; if (collectType != null) { Mapping.Collection collection = collectType.Create(subnode, className, subpath, model.Owner, model.ComponentClass, mappings); mappings.AddCollection(collection); value = collection; } else if ("many-to-one".Equals(name) || "key-many-to-one".Equals(name)) { value = new ManyToOne(model.Table); BindManyToOne(subnode, (ManyToOne) value, subpath, isNullable, mappings); } else if ("one-to-one".Equals(name)) { value = new OneToOne(model.Table, model.Owner.Identifier); BindOneToOne(subnode, (OneToOne) value, isNullable, mappings); } else if ("any".Equals(name)) { value = new Any(model.Table); BindAny(subnode, (Any) value, isNullable, mappings); } else if ("property".Equals(name) || "key-property".Equals(name)) { value = new SimpleValue(model.Table); BindSimpleValue(subnode, (SimpleValue) value, isNullable, subpath, mappings); } else if ("component".Equals(name) || "dynamic-component".Equals(name) || "nested-composite-element".Equals(name)) { System.Type subreflectedClass = model.ComponentClass == null ? null : GetPropertyType(subnode, mappings, model.ComponentClass, propertyName); value = (model.Owner != null) ? new Component(model.Owner) : // a class component new Component(model.Table); // a composite element BindComponent(subnode, (Component) value, subreflectedClass, className, subpath, isNullable, mappings); } else if ("parent".Equals(name)) { model.ParentProperty = propertyName; } if (value != null) { model.AddProperty(CreateProperty(value, propertyName, model.ComponentClass, subnode, mappings)); } } int span = model.PropertySpan; string[] names = new string[span]; IType[] types = new IType[span]; bool[] nullabilities = new bool[span]; Cascades.CascadeStyle[] cascade = new Cascades.CascadeStyle[span]; FetchMode[] joinedFetch = new FetchMode[span]; int i = 0; foreach (Mapping.Property prop in model.PropertyCollection) { names[i] = prop.Name; types[i] = prop.Type; nullabilities[i] = prop.IsNullable; cascade[i] = prop.CascadeStyle; joinedFetch[i] = prop.Value.FetchMode; i++; } IType componentType; if (model.IsDynamic) { componentType = new DynamicComponentType(names, types, nullabilities, joinedFetch, cascade); } else { IGetter[] getters = new IGetter[span]; ISetter[] setters = new ISetter[span]; bool foundCustomAccessor = false; i = 0; foreach (Mapping.Property prop in model.PropertyCollection) { setters[i] = prop.GetSetter(model.ComponentClass); getters[i] = prop.GetGetter(model.ComponentClass); if (!prop.IsBasicPropertyAccessor) { foundCustomAccessor = true; } i++; } componentType = new ComponentType( model.ComponentClass, names, getters, setters, foundCustomAccessor, types, nullabilities, joinedFetch, cascade, model.ParentProperty); } model.Type = componentType; }