public override bool IsNull(ISpmContext context, int index) { SpmItem <TValue> itemReader = (SpmItem <TValue>)context[this.propertyToken]; if (itemReader == null) { itemReader = new SpmItem <TValue>(context, this.Mapped, null); context[this.propertyToken] = itemReader; } return(itemReader.IsKeysNull()); }
public override void Read(ISpmContext context, int index, TItem dest) { SpmItem <TValue> itemReader = (SpmItem <TValue>)context[this.propertyToken]; if (itemReader == null) { itemReader = new SpmItem <TValue>(context, this.Mapped, null); context[this.propertyToken] = itemReader; } this.setter(dest, itemReader.Read()); }
public override void Read(ISpmContext context, int index, TItem dest) { if (context.DataReader.IsDBNull(index)) { this.setter(dest, null); } else { this.setter(dest, read(context.DataReader, index)); } }
public SpmItem(ISpmContext readContext, SpmAttribute mappedHolder, string group) { if (readContext == null) { throw new ArgumentNullException("itemReader"); } this.context = readContext; this.MappedHolder = mappedHolder; ReadOnlyCollection <ISpmAccessor <TItem> > coll = SpmAccessors <TItem> .Collection; this.accessors = new List <SprIndexedAccessor>(coll.Count); this.keys = new List <SprIndexedAccessor>(4); for (int i = 0; i < coll.Count; i++) { ISpmAccessor <TItem> accessor = coll[i]; if (accessor.Mapped.InGroup(group)) { string[] colNames = accessor.Mapped.Columns; int index = -1; for (int j = 0; j < colNames.Length; j++) { string colName = colNames[j]; if (colName.StartsWith("/")) { if (this.MappedHolder == null || !this.MappedHolder.HasSynonyms) { throw new ArgumentException(String.Concat("Не заданы родительские синонимы для", colNames[j])); } if (String.IsNullOrEmpty((colName = this.MappedHolder.GetSynonim(colName.Substring(1))))) { throw new ArgumentException(String.Concat("Не найдена ссылка на родительский синоним ", colNames[j])); } } if ((index = this.context.TryGetIndex(colName)) >= 0) { break; } } if (index < 0 && colNames.Length > 0) { throw new ArgumentException(String.Concat("В результате запроса не найдено хотя бы одно из полей: ", String.Join(", ", colNames))); } SprIndexedAccessor indexedAccessor = new SprIndexedAccessor(index, accessor); this.accessors.Add(indexedAccessor); if (accessor.Mapped.Key) { keys.Add(indexedAccessor); } } } this.accessors.TrimExcess(); if (mappedHolder != null && mappedHolder.Shared) { this.sharedItems = readContext.SharedPool.Get <TItem>(mappedHolder.ShareId, out this.extendable); if (this.sharedItems == null) { this.sharedItems = new Dictionary <TItem, TItem>(10); readContext.SharedPool.Set(mappedHolder.ShareId, this.sharedItems, true); this.extendable = true; } else if (this.keys.Count == 0 && !this.extendable) { throw new ArgumentException("Не заданы ключи для использования фиксированного пула элементов."); } this.sharedItem = new TItem(); } }
public override void Read(ISpmContext context, int index, TItem dest) { this.setter(dest, context.DataReader.IsDBNull(index) ? default(TValue) : read(context.DataReader, index)); }
public virtual bool IsNull(ISpmContext context, int index) { return(context.DataReader.IsDBNull(index)); }
public abstract void Read(ISpmContext context, int index, TItem dest);