public EntityClonerField(EntityField2 field) { _fieldIndex = field.FieldIndex; _containingObjectName = field.ContainingObjectName; _name = field.Name; _isPrimaryKey = field.IsPrimaryKey; }
public static int GetDbCount(IRelationPredicateBucket filter, EntityField2 fieldStatus) { EntityCollection ec = new EntityCollection(new TEntityFactory()); using (DataAccessAdapter adapter = DataAccessAdapterManagerBase.CreateAdapter()) { filter.PredicateExpression.Add(fieldStatus == true); return(adapter.GetDbCount(ec, filter)); } }
/// <summary> /// Returns valid entities which are valid for given moment in time. /// Valid entities have: /// 1. Begining is not NULL AND is LESS than given moment in time. /// 2. End is NULL OR is GREATER OR EQUAL than given moment in time. /// </summary> public static PredicateExpression FilterValidEntities(DateTime momentInTime, EntityField2 validFromDateTimeField, EntityField2 validToDateTimeField) { PredicateExpression predicateExpression = new PredicateExpression(); predicateExpression.Add(validFromDateTimeField != DBNull.Value & validFromDateTimeField <= momentInTime); predicateExpression.AddWithAnd(validToDateTimeField == DBNull.Value | validToDateTimeField >= momentInTime); return predicateExpression; }
public static EntityCollection SelectAll(int iTop, ISortExpression sorter, EntityField2 fieldStatus, IRelationPredicateBucket filter) { EntityCollection ec = new EntityCollection(new TEntityFactory()); using (DataAccessAdapter adapter = DataAccessAdapterManagerBase.CreateAdapter()) { filter.PredicateExpression.Add(fieldStatus == true); adapter.FetchEntityCollection(ec, filter, iTop, sorter); } return(ec); }
/// <summary> /// Gets a collection of Products sorted by the passed in field, and direction of sort. /// </summary> /// <param name="sortFieldName">Name of the sort field.</param> /// <param name="direction">direction of sort</param> /// <returns>a sorted products collection</returns> /// <remarks>Shows how to use message parameters to specify sorting. /// </remarks> public IEntityCollection2 GetProductsSortedBy(EntityField2 sortField, SortOperator direction) { var toReturn = new EntityCollection(new ProductEntityFactory()); using (DataAccessAdapter adapter = new DataAccessAdapter()) { // fetch all products, sorted on the sort expression passed in adapter.FetchEntityCollection(toReturn, null, 0, new SortExpression(new SortClause(sortField, null, direction))); } return(toReturn); }
public static EntityCollection SelectByField(EntityField2 fieldColumn, object fkValue) { EntityCollection ec = new EntityCollection(new TEntityFactory()); RelationPredicateBucket filter = new RelationPredicateBucket(); filter.PredicateExpression.Add(fieldColumn == fkValue); using (DataAccessAdapter adapter = DataAccessAdapterManagerBase.CreateAdapter()) { adapter.FetchEntityCollection(ec, filter, 0, null); } return(ec); }
/// <summary> /// Creates a predicate from the passed in data. /// </summary> /// <param name="field">The field.</param> /// <param name="operatorID">The operator ID.</param> /// <param name="negate">if set to <c>true</c> [negate].</param> /// <param name="fromValue">From value.</param> /// <param name="toValue">To value.</param> /// <returns> /// Predicate object which filters on the field with the specified values, or null if no predicate could be created. /// </returns> public static IPredicate CreatePredicate(EntityField2 field, int operatorID, bool negate, object fromValue, object toValue) { IPredicate toReturn = null; switch (operatorID) { case 0: // equal toReturn = new FieldCompareValuePredicate(field, null, ComparisonOperator.Equal, fromValue, negate); break; case 1: // greater toReturn = new FieldCompareValuePredicate(field, null, ComparisonOperator.GreaterThan, fromValue, negate); break; case 2: // greater / equal toReturn = new FieldCompareValuePredicate(field, null, ComparisonOperator.GreaterEqual, fromValue, negate); break; case 3: // lesser toReturn = new FieldCompareValuePredicate(field, null, ComparisonOperator.LesserThan, fromValue, negate); break; case 4: // lesser / equal toReturn = new FieldCompareValuePredicate(field, null, ComparisonOperator.LessEqual, fromValue, negate); break; case 5: // between if (toValue == null) { // invalid return(null); } toReturn = new FieldBetweenPredicate(field, null, fromValue, toValue, negate); break; case 6: // null toReturn = new FieldCompareNullPredicate(field, null, negate); break; case 7: // like toReturn = new FieldLikePredicate(field, null, (string)fromValue, negate); break; default: // invalid operator return(null); } return(toReturn); }
/// <summary> Creates a new IEntityField2 instance for usage in the EntityFields object for the ProductEntity. Which EntityField is created is specified by fieldIndex</summary> /// <param name="fieldIndex">The field which IEntityField2 instance should be created</param> /// <returns>The IEntityField2 instance for the field specified in fieldIndex</returns> public static IEntityField2 Create(ProductFieldIndex fieldIndex) { IEntityField2 fieldToReturn = null; switch(fieldIndex) { case ProductFieldIndex.Id: fieldToReturn = new EntityField2("Id", "ProductEntity", typeof(System.Int32), TypeDefaultValue.GetDefaultValue(typeof(System.Int32)), true, (int)fieldIndex, 0, 0, 10, false, true, false); break; case ProductFieldIndex.Name: fieldToReturn = new EntityField2("Name", "ProductEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), false, (int)fieldIndex, 255, 0, 0, false, false, true); break; case ProductFieldIndex.Description: fieldToReturn = new EntityField2("Description", "ProductEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), false, (int)fieldIndex, 536870911, 0, 0, false, false, true); break; case ProductFieldIndex.Price: fieldToReturn = new EntityField2("Price", "ProductEntity", typeof(System.Decimal), TypeDefaultValue.GetDefaultValue(typeof(System.Decimal)), false, (int)fieldIndex, 0, 0, 19, false, false, true); break; case ProductFieldIndex.PriceIncludesVat: fieldToReturn = new EntityField2("PriceIncludesVat", "ProductEntity", typeof(System.Boolean), TypeDefaultValue.GetDefaultValue(typeof(System.Boolean)), false, (int)fieldIndex, 2, 0, 0, false, false, false); break; case ProductFieldIndex.ImageName: fieldToReturn = new EntityField2("ImageName", "ProductEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), false, (int)fieldIndex, 255, 0, 0, false, false, true); break; case ProductFieldIndex.SectionId: fieldToReturn = new EntityField2("SectionId", "ProductEntity", typeof(System.Int32), TypeDefaultValue.GetDefaultValue(typeof(System.Int32)), false, (int)fieldIndex, 0, 0, 10, true, false, true); break; case ProductFieldIndex.ExtraInformation: fieldToReturn = new EntityField2("ExtraInformation", "ProductEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), false, (int)fieldIndex, 536870911, 0, 0, false, false, true); break; case ProductFieldIndex.DeliveryPrice: fieldToReturn = new EntityField2("DeliveryPrice", "ProductEntity", typeof(System.Decimal), TypeDefaultValue.GetDefaultValue(typeof(System.Decimal)), false, (int)fieldIndex, 0, 0, 19, false, false, true); break; case ProductFieldIndex.PriceIsFrom: fieldToReturn = new EntityField2("PriceIsFrom", "ProductEntity", typeof(System.Boolean), TypeDefaultValue.GetDefaultValue(typeof(System.Boolean)), false, (int)fieldIndex, 2, 0, 0, false, false, false); break; case ProductFieldIndex.SortIndex: fieldToReturn = new EntityField2("SortIndex", "ProductEntity", typeof(System.Int16), TypeDefaultValue.GetDefaultValue(typeof(System.Int16)), false, (int)fieldIndex, 0, 0, 5, false, false, true); break; case ProductFieldIndex.Enabled: fieldToReturn = new EntityField2("Enabled", "ProductEntity", typeof(System.Boolean), TypeDefaultValue.GetDefaultValue(typeof(System.Boolean)), false, (int)fieldIndex, 2, 0, 0, false, false, false); break; } return fieldToReturn; }
/// <summary> /// Returns entites which validityDateTimeField is GREATER OR EQUAL than startDateTime, /// and LESS than endDateTime. public static PredicateExpression FilterValidEntities(DateTime? startDateTime, DateTime? endDateTime, EntityField2 validityDateTimeField) { PredicateExpression predicateExpression = new PredicateExpression(); if (null != startDateTime) { predicateExpression.Add(validityDateTimeField >= startDateTime.Value); } if (null != endDateTime) { predicateExpression.Add(validityDateTimeField < endDateTime.Value); } return predicateExpression; }
/// <summary> /// Creates a predicate from the passed in data. /// </summary> /// <param name="field">The field.</param> /// <param name="operatorID">The operator ID.</param> /// <param name="negate">if set to <c>true</c> [negate].</param> /// <param name="fromValueAsString">From value as string.</param> /// <param name="toValueAsString">To value as string.</param> /// <returns>Predicate object which filters on the field with the specified values, or null if no predicate could be created.</returns> public static IPredicate CreatePredicate(EntityField2 field, int operatorID, bool negate, string fromValueAsString, string toValueAsString) { object fromValue = null; object toValue = null; if (operatorID != 6) { // NULL operator doesn't require input values, all other operators do, so test input values when operator isn't the NULL operator if (fromValueAsString.Length > 0) { try { fromValue = Convert.ChangeType(fromValueAsString, field.DataType); } catch { // value isn't valid, return(null); } } if (toValueAsString.Length > 0) { try { toValue = Convert.ChangeType(toValueAsString, field.DataType); } catch { // value specified and not valid. return(null); } } if (fromValue == null) { // invalid value specified return(null); } } return(CreatePredicate(field, operatorID, negate, fromValue, toValue)); }
/// <summary> /// Returns predicate which returns single (on none) entity for given moment in time. /// Vraća predikat koji filtrira jedan entitet koji je validan za dani momentInTime. /// </summary> /// <param name="setFilter">Additional filter which applies before datetime predicate.</param> public static PredicateExpression FilterValidEntities(DateTime momentInTime, EntityField2 validDateTimeField, IPredicateExpression setFilter) { PredicateExpression newSetFilter; if (null != setFilter) { newSetFilter = new PredicateExpression(setFilter); newSetFilter.AddWithAnd(validDateTimeField <= momentInTime); } else { newSetFilter = new PredicateExpression(validDateTimeField <= momentInTime); } PredicateExpression toReturn = new PredicateExpression(); toReturn.Add(validDateTimeField <= momentInTime); toReturn.Add(new FieldCompareSetPredicate(validDateTimeField, null, validDateTimeField, null, SetOperator.GreaterEqualAll, newSetFilter)); return toReturn; }
/// <summary> Creates a new IEntityField2 instance for usage in the EntityFields object for the UserRoleLinkEntity. Which EntityField is created is specified by fieldIndex</summary> /// <param name="fieldIndex">The field which IEntityField2 instance should be created</param> /// <returns>The IEntityField2 instance for the field specified in fieldIndex</returns> public static IEntityField2 Create(UserRoleLinkFieldIndex fieldIndex) { IEntityField2 fieldToReturn = null; switch(fieldIndex) { case UserRoleLinkFieldIndex.UserId: fieldToReturn = new EntityField2("UserId", "UserRoleLinkEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), true, (int)fieldIndex, 50, 0, 0, true, false, true); break; case UserRoleLinkFieldIndex.RoleName: fieldToReturn = new EntityField2("RoleName", "UserRoleLinkEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), true, (int)fieldIndex, 50, 0, 0, true, false, true); break; } return fieldToReturn; }
private static Predicate CreatePredicateForType(EntityField2 filterField, string data) { Predicate predicate = null; if (filterField.DataType == typeof(string)) { FieldLikePredicate likePredicate = new FieldLikePredicate(filterField, null, string.Format("{0}%", data.ToUpper())); likePredicate.CaseSensitiveCollation = true; predicate = likePredicate; } else if (filterField.DataType == typeof(bool)) { bool boolData; if (bool.TryParse(data, out boolData)) { predicate = filterField == boolData; } } else if (filterField.DataType == typeof(byte)) { byte byteData; if (byte.TryParse(data, out byteData)) { predicate = filterField == byteData; } } else if (filterField.DataType == typeof(short)) { short shortData; if (short.TryParse(data, out shortData)) { predicate = filterField == shortData; } } else if (filterField.DataType == typeof(int)) { int intData; if (int.TryParse(data, out intData)) { predicate = filterField == intData; } } else if (filterField.DataType == typeof(long)) { long longData; if (long.TryParse(data, out longData)) { predicate = filterField == longData; } } else if (filterField.DataType == typeof(Single)) { Single singleData; if (Single.TryParse(data, out singleData)) { predicate = filterField == singleData; } } else if (filterField.DataType == typeof(double)) { double doubleData; if (double.TryParse(data, out doubleData)) { predicate = filterField == doubleData; } } else if (filterField.DataType == typeof(decimal)) { decimal decimalData; if (decimal.TryParse(data, out decimalData)) { predicate = filterField == decimalData; } } return predicate; }
/// <summary> Creates a new IEntityField2 instance for usage in the EntityFields object for the ProductVariationEntity. Which EntityField is created is specified by fieldIndex</summary> /// <param name="fieldIndex">The field which IEntityField2 instance should be created</param> /// <returns>The IEntityField2 instance for the field specified in fieldIndex</returns> public static IEntityField2 Create(ProductVariationFieldIndex fieldIndex) { IEntityField2 fieldToReturn = null; switch(fieldIndex) { case ProductVariationFieldIndex.Id: fieldToReturn = new EntityField2("Id", "ProductVariationEntity", typeof(System.Int32), TypeDefaultValue.GetDefaultValue(typeof(System.Int32)), true, (int)fieldIndex, 0, 0, 10, false, true, false); break; case ProductVariationFieldIndex.ProductId: fieldToReturn = new EntityField2("ProductId", "ProductVariationEntity", typeof(System.Int32), TypeDefaultValue.GetDefaultValue(typeof(System.Int32)), false, (int)fieldIndex, 0, 0, 10, true, false, true); break; case ProductVariationFieldIndex.Price: fieldToReturn = new EntityField2("Price", "ProductVariationEntity", typeof(System.Decimal), TypeDefaultValue.GetDefaultValue(typeof(System.Decimal)), false, (int)fieldIndex, 0, 0, 19, false, false, true); break; case ProductVariationFieldIndex.PriceIncludesVat: fieldToReturn = new EntityField2("PriceIncludesVat", "ProductVariationEntity", typeof(System.Boolean), TypeDefaultValue.GetDefaultValue(typeof(System.Boolean)), false, (int)fieldIndex, 2, 0, 0, false, false, false); break; case ProductVariationFieldIndex.PriceIsFrom: fieldToReturn = new EntityField2("PriceIsFrom", "ProductVariationEntity", typeof(System.Boolean), TypeDefaultValue.GetDefaultValue(typeof(System.Boolean)), false, (int)fieldIndex, 2, 0, 0, false, false, false); break; case ProductVariationFieldIndex.Text: fieldToReturn = new EntityField2("Text", "ProductVariationEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), false, (int)fieldIndex, 100, 0, 0, false, false, true); break; } return fieldToReturn; }
public Field(EntityField2 entityField) : this(entityField.Name) { }
/// <summary> Creates a new IEntityField2 instance for usage in the EntityFields object for the RoleEntity. Which EntityField is created is specified by fieldIndex</summary> /// <param name="fieldIndex">The field which IEntityField2 instance should be created</param> /// <returns>The IEntityField2 instance for the field specified in fieldIndex</returns> public static IEntityField2 Create(RoleFieldIndex fieldIndex) { IEntityField2 fieldToReturn = null; switch(fieldIndex) { case RoleFieldIndex.Name: fieldToReturn = new EntityField2("Name", "RoleEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), true, (int)fieldIndex, 100, 0, 0, false, false, true); break; } return fieldToReturn; }
/// <summary> /// Nullable field'lar için (ID, IsActive gibi) FilterPredicate üreterek filterPredicateExpression'a ekler. /// </summary> /// <param name="filterPredicateExpression">Filtre</param> /// <param name="field">EntityField</param> /// <param name="nullableList"></param> protected void AddNullableFieldEqualsToFilter(ref IPredicateExpression filterPredicateExpression, EntityField2 field, IList nullableList) { if (nullableList != null && nullableList.Count > 0) { AddNullableFieldFilter(ref filterPredicateExpression, field == nullableList, nullableList); } }
/// <summary> /// Nullable field'lar için (ID, IsActive gibi) FilterPredicate üreterek filterPredicateExpression'a ekler. /// </summary> /// <param name="filterPredicateExpression">Filtre</param> /// <param name="field">EntityField</param> /// <param name="nullableParameter">Nullable Parametre (ID değeri gibi)</param> protected void AddNullableFieldEqualsToFilter(ref IPredicateExpression filterPredicateExpression, EntityField2 field, object nullableParameter) { AddNullableFieldFilter(ref filterPredicateExpression, field == nullableParameter, nullableParameter); }
/// <summary> Creates a new IEntityField2 instance for usage in the EntityFields object for the ProductSectionEntity. Which EntityField is created is specified by fieldIndex</summary> /// <param name="fieldIndex">The field which IEntityField2 instance should be created</param> /// <returns>The IEntityField2 instance for the field specified in fieldIndex</returns> public static IEntityField2 Create(ProductSectionFieldIndex fieldIndex) { IEntityField2 fieldToReturn = null; switch(fieldIndex) { case ProductSectionFieldIndex.Id: fieldToReturn = new EntityField2("Id", "ProductSectionEntity", typeof(System.Int32), TypeDefaultValue.GetDefaultValue(typeof(System.Int32)), true, (int)fieldIndex, 0, 0, 10, false, true, false); break; case ProductSectionFieldIndex.ParentSectionId: fieldToReturn = new EntityField2("ParentSectionId", "ProductSectionEntity", typeof(System.Int32), TypeDefaultValue.GetDefaultValue(typeof(System.Int32)), false, (int)fieldIndex, 0, 0, 10, true, false, true); break; case ProductSectionFieldIndex.Uri: fieldToReturn = new EntityField2("Uri", "ProductSectionEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), false, (int)fieldIndex, 255, 0, 0, false, false, true); break; case ProductSectionFieldIndex.Name: fieldToReturn = new EntityField2("Name", "ProductSectionEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), false, (int)fieldIndex, 100, 0, 0, false, false, true); break; } return fieldToReturn; }
/// <summary> Creates a new IEntityField2 instance for usage in the EntityFields object for the SpecialOfferEntity. Which EntityField is created is specified by fieldIndex</summary> /// <param name="fieldIndex">The field which IEntityField2 instance should be created</param> /// <returns>The IEntityField2 instance for the field specified in fieldIndex</returns> public static IEntityField2 Create(SpecialOfferFieldIndex fieldIndex) { IEntityField2 fieldToReturn = null; switch(fieldIndex) { case SpecialOfferFieldIndex.Id: fieldToReturn = new EntityField2("Id", "SpecialOfferEntity", typeof(System.Int32), TypeDefaultValue.GetDefaultValue(typeof(System.Int32)), true, (int)fieldIndex, 0, 0, 10, false, true, false); break; case SpecialOfferFieldIndex.ProductId: fieldToReturn = new EntityField2("ProductId", "SpecialOfferEntity", typeof(System.Int32), TypeDefaultValue.GetDefaultValue(typeof(System.Int32)), false, (int)fieldIndex, 0, 0, 10, true, false, true); break; case SpecialOfferFieldIndex.Number: fieldToReturn = new EntityField2("Number", "SpecialOfferEntity", typeof(System.Int16), TypeDefaultValue.GetDefaultValue(typeof(System.Int16)), false, (int)fieldIndex, 0, 0, 5, false, false, true); break; } return fieldToReturn; }
/// <summary> Creates a new IEntityField2 instance for usage in the EntityFields object for the UserEntity. Which EntityField is created is specified by fieldIndex</summary> /// <param name="fieldIndex">The field which IEntityField2 instance should be created</param> /// <returns>The IEntityField2 instance for the field specified in fieldIndex</returns> public static IEntityField2 Create(UserFieldIndex fieldIndex) { IEntityField2 fieldToReturn = null; switch(fieldIndex) { case UserFieldIndex.UserId: fieldToReturn = new EntityField2("UserId", "UserEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), true, (int)fieldIndex, 50, 0, 0, false, false, true); break; case UserFieldIndex.FirstName: fieldToReturn = new EntityField2("FirstName", "UserEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), false, (int)fieldIndex, 50, 0, 0, false, false, true); break; case UserFieldIndex.LastName: fieldToReturn = new EntityField2("LastName", "UserEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), false, (int)fieldIndex, 50, 0, 0, false, false, true); break; case UserFieldIndex.Password: fieldToReturn = new EntityField2("Password", "UserEntity", typeof(System.String), TypeDefaultValue.GetDefaultValue(typeof(System.String)), false, (int)fieldIndex, 536870911, 0, 0, false, false, true); break; } return fieldToReturn; }