当前位置: 首页>>代码示例>>C#>>正文


C# EntityKey类代码示例

本文整理汇总了C#中EntityKey的典型用法代码示例。如果您正苦于以下问题:C# EntityKey类的具体用法?C# EntityKey怎么用?C# EntityKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EntityKey类属于命名空间,在下文中一共展示了EntityKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Resolve

    public EntityError Resolve(EntityManager em) {
      IsServerError = true;
      try {
        EntityType entityType = null;
        if (EntityTypeName != null) {
          var stName = TypeNameInfo.FromClrTypeName(EntityTypeName).ToClient(em.MetadataStore).StructuralTypeName;
          entityType = em.MetadataStore.GetEntityType(stName);
          var ek = new EntityKey(entityType, KeyValues);
          Entity = em.GetEntityByKey(ek);
        }

        
        if (entityType != null) {
          if (PropertyName != null) {
            Property = entityType.Properties.FirstOrDefault(p => p.NameOnServer == PropertyName);
            if (Property != null) {
              PropertyName = Property.Name;
            }
          }
          
          var vc = new ValidationContext(this.Entity);
          vc.Property = Property;
          var veKey = (ErrorName ?? ErrorMessage) + (PropertyName ?? "");
          var ve = new ValidationError(null, vc, ErrorMessage, veKey);
          ve.IsServerError = true;
          this.Entity.EntityAspect.ValidationErrors.Add(ve);
        }
      } catch (Exception e) {
        ErrorMessage = ( ErrorMessage ?? "") + ":  Unable to Resolve this error: " + e.Message;
      }
      return this;
    }
开发者ID:novice3030,项目名称:breeze.sharp,代码行数:32,代码来源:SaveException.cs

示例2: EnviarCorreoUsuarioNuevo

        /// <summary>
        /// Envia correo de usuario nuevo.
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <param name="USR_PASSWORD"></param>
        /// <param name="Configuracion"></param>
        public static void EnviarCorreoUsuarioNuevo(string USR_USERNAME, string USR_PASSWORD, XmlDocument Configuracion)
        {
            try
            {
                UsuarioLogic usuariologica = new UsuarioLogic();
                usuario user = usuariologica.GetUsuario(USR_USERNAME);

                string mailto = user.USR_CORREO;
                string nombre = user.USR_NOMBRE + " " + user.USR_APELLIDO;

                string subject = "";
                string message = "";

                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.plantillas_notificaciones", "PLANTILLAS_LLAVE", "USUARIONUEVO");
                    var pl = db.GetObjectByKey(k);
                    plantilla_notificacion plantilla = (plantilla_notificacion)pl;

                    subject = plantilla.PLANTILLAS_ASUNTO;
                    message = plantilla.PLANTILLAS_MENSAJE;
                }

                message = message.Replace("{NOMBRE}", nombre);
                message = message.Replace("{USUARIO}", USR_USERNAME);
                message = message.Replace("{CONTRASEÑA}", USR_PASSWORD);

                EnviarCorreo(mailto, subject, message, Configuracion);
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al enviar correo de usuario nuevo.", ex);
                throw;
            }
        }
开发者ID:xapiz,项目名称:COCASJOL,代码行数:41,代码来源:EmailLogic.cs

示例3: ApplyChanges

        public void ApplyChanges(MappingSet mappingSet, EntityKey key)
        {
            // Create new Component
            var component = existingSpecToUse.CreateImplementedComponentFor(key.Parent, newComponentName);

            // Set mapped column on the new Component's properties.
            foreach(var pair in propertyMappings)
            {
                var newProperty = component.GetProperty(pair.Key);
                var oldProperty = key.Properties.FirstOrDefault(p => p.Name == pair.Value);

                if(oldProperty == null)
                {
                    // Something went horribly wrong. We have a Property that has been mapped,
                    // but it doesn't actually exist. I am chosing to ignore this here, but log it.
                    log.ErrorFormat("Property {0} was mapped in the ConvertKeyToComponent wizard, but doesn't actually exist in the model.", pair.Value);
                    continue;
                }

                newProperty.SetMappedColumn(oldProperty.MappedColumn());
            }

            // Delete existing properties if needed.
            if(deleteExistingProperties)
            {
                foreach(var property in key.Properties.ToList())
                {
                    property.DeleteSelf();
                }
            }

            key.Component = component;
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:33,代码来源:ConvertKeyToComponentResults.cs

示例4: LookupByPrimaryKey

 public EntityRecord LookupByPrimaryKey(EntityKey primaryKey)
 {
     EntityRecord rec;
       if (RecordsByPrimaryKey.TryGetValue(primaryKey, out rec))
     return rec;
       return null;
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:7,代码来源:FullyCachedSet.cs

示例5: AddOrUpdate

        public void AddOrUpdate(System.Globalization.CultureInfo culture, EntityKey key, IEnumerable<PropertyTranslation> propertyTranslations)
        {
            using (var db = new MultilingualDbContext(InstanceName))
            {
                var entry = db.Translations.Find(GetUnderlyingEntityKey(culture.Name, key));
                if (entry == null)
                {
                    entry = new EntityTranslationDbEntry
                    {
                        Culture = culture.Name,
                        EntityType = key.EntityType.Name,
                        EntityKey = key.Value.ToString()
                    };

                    entry.Properties = JsonConvert.SerializeObject(propertyTranslations);
                    db.Translations.Add(entry);
                }
                else
                {
                    entry.Properties = JsonConvert.SerializeObject(propertyTranslations);
                    entry.IsOutOfDate = false;
                }

                db.SaveChanges();

                Event.Raise(new TranslationUpdated(key, propertyTranslations, culture), GetInstance());
            }
        }
开发者ID:Kooboo,项目名称:Ecommerce,代码行数:28,代码来源:SqlceTranslationStore.cs

示例6: Main

        static void Main(string[] args)
        {
            using (VS2010Entities ie = new VS2010Entities())
            {
                EntityKey ek = new EntityKey("VS2010Entities.PESSOA", "COD_PESSOA", 8);

                PESSOA p = (PESSOA)ie.GetObjectByKey(ek);

                if (p != null)
                    p.NOME_PESSOA = "EMA FROST";

                foreach (var item in ie.PESSOA)
                {
                    Console.WriteLine(item.NOME_PESSOA);
                }

                Console.WriteLine("------------------------");

                ie.SaveChanges();

                foreach (var item in ie.PESSOA)
                {
                    Console.WriteLine(item.NOME_PESSOA);
                }

                Console.ReadKey();
            }
        }
开发者ID:50minutos,项目名称:VS2010,代码行数:28,代码来源:Program.cs

示例7: BriefView

 public BriefView(int id, bool w)
 {
     obj = new TravelDAL.Tour();
     using (var context = new TravelDBEntities())
     {
         EntityKey key = new EntityKey("TravelDBEntities.Tour", "IDTour", id);
         obj = (TravelDAL.Tour)context.GetObjectByKey(key);
         if (obj != null)
         {
             tourname = obj.Name;
             addinfo = obj.AdditionalInfo;
             if (addinfo.Length > 120) addinfo = addinfo.Substring(0, 120);
             addinfo += "...";
             minprice = obj.MinimalPrice.ToString();
             avgprice = obj.AveragePrice.ToString();
             rating = obj.AverageMark.ToString();
             wide = w;
             foreach (TravelDAL.Country m in obj.Country)
             {
                 countrynames += m.Name;
                 countrynames += " ";
             }
         }
     }
 }
开发者ID:antonchaika,项目名称:TravelAgencyWebSite,代码行数:25,代码来源:BriefView.ascx.cs

示例8: RemoveByID

        /// <summary>
        /// Removes the Category by ID.
        /// </summary>
        /// <param name="categoryID">The category ID.</param>
        public static void RemoveByID(int categoryID)
        {
            object categoryForDeletion;

            EntityKey categoryKey = new EntityKey("WebCalendarEntities.Categories", "ID", categoryID);

            if (db.TryGetObjectByKey(categoryKey, out categoryForDeletion))
            {
                try
                {
                    db.DeleteObject(categoryForDeletion);
                    db.SaveChanges();
                }
                catch (OptimisticConcurrencyException ex)
                {
                    throw new InvalidOperationException(string.Format(
                                                                      "The Category with an ID of '{0}' could not be deleted.\n" +
                                                                      "Make sure that any related objects are already deleted.\n",
                        categoryKey.EntityKeyValues[0].Value), ex);
                }
            }
            else
            {
                throw new InvalidOperationException(string.Format(
                                                                  "The Category with an ID of '{0}' could not be found.\n" +
                                                                  "Make sure that Category exists.\n",
                    categoryKey.EntityKeyValues[0].Value));
            }
        }
开发者ID:mitev-web,项目名称:web-calendar,代码行数:33,代码来源:CategoryDAL.cs

示例9: CreateConceptualNullKey

        /// <summary>
        /// Creates an EntityKey that represents a Conceptual Null
        /// </summary>
        /// <param name="originalKey">An EntityKey representing the existing FK values that could not be nulled</param>
        /// <returns>EntityKey marked as a conceptual null with the FK values from the original key</returns>
        public static EntityKey CreateConceptualNullKey(EntityKey originalKey)
        {
            Debug.Assert(originalKey != null, "Original key can not be null");

            //Conceptual nulls have special entity set name and a copy of the previous values
            EntityKey nullKey = new EntityKey(s_NullForeignKey, originalKey.EntityKeyValues);
            return nullKey;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:13,代码来源:ForeignKeyFactory.cs

示例10: CreateConceptualNullKey

        /// <summary>
        ///     Creates an EntityKey that represents a Conceptual Null
        /// </summary>
        /// <param name="originalKey"> An EntityKey representing the existing FK values that could not be nulled </param>
        /// <returns> EntityKey marked as a conceptual null with the FK values from the original key </returns>
        public static EntityKey CreateConceptualNullKey(EntityKey originalKey)
        {
            DebugCheck.NotNull(originalKey);

            //Conceptual nulls have special entity set name and a copy of the previous values
            var nullKey = new EntityKey(s_NullForeignKey, originalKey.EntityKeyValues);
            return nullKey;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:13,代码来源:ForeignKeyFactory.cs

示例11: AddEntityToIndex

            public void AddEntityToIndex(EntityKey entityKey, Document doc)
            {
                // when creating a projection index, the entity key should not be passed
                Debug.Assert(entityKey == null);

                // adding document to index
                this._index.AddEntity(doc);
            }
开发者ID:LCHarold,项目名称:linq2dynamodb,代码行数:8,代码来源:EnyimProjectionIndexCreator.cs

示例12: Dump

        /// <summary>
        /// Private extension method for ObjectStateManager class
        /// Dump all tracking info to a string 
        /// </summary>
        /// <param name="manager">ObjectStateManager</param>
        /// <param name="objectStateEntries">Collection of ObjectStateEntries. If null, then all entities will be displayed</param>
        /// <param name="entityKey">EntityKey of given entity. If null, then all entities will be displayed</param>
        /// <param name="asHtml">Output string as HTML</param>
        /// <returns>String with tracking info about entries</returns>
        private static string Dump(
          ObjectStateManager manager,
          IEnumerable<ObjectStateEntry> objectStateEntries,
          EntityKey entityKey,
          bool asHtml)
        {
            StringBuilder dump = new StringBuilder();

            if (entityKey != null)
            {
                objectStateEntries = new List<ObjectStateEntry>();
                (objectStateEntries as List<ObjectStateEntry>).Add(manager.GetObjectStateEntry(entityKey));
            }
            else if (objectStateEntries == null)
            {
                objectStateEntries = manager.GetObjectStateEntries(~EntityState.Detached);
            }

            dump.AppendFormat("ObjectStateManager entries : # {0}\n", objectStateEntries.Count());

            foreach (var entry in objectStateEntries)
            {
                dump.Append(ObjectStateEntryToString(entry));

                if (entry.State == EntityState.Added)
                {
                    for (int i = 0; i < entry.CurrentValues.FieldCount; i++)
                    {
                        dump.AppendFormat("\n\t- {0} = {1}",
                          entry.CurrentValues.GetName(i),
                          ObjectToString(entry.CurrentValues[i]));
                    }
                }
                else if (entry.State == EntityState.Modified)
                {
                    foreach (string prop in entry.GetModifiedProperties())
                    {
                        dump.AppendFormat("\n\t- {0} : {1} -> {2}",
                            prop,
                            ObjectToString(entry.OriginalValues[prop]),
                            ObjectToString(entry.CurrentValues[prop]));
                    }
                }
            }

            if (asHtml)
            {
                dump.Replace("\n", "<br />");
                dump.Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
            }
            else
            {
                dump.Replace("<b>", "");
                dump.Replace("</b>", "");
            }

            return dump.ToString();
        }
开发者ID:alejsherion,项目名称:gggets,代码行数:67,代码来源:ObjectStateManagerExtensions.cs

示例13: EntityRecordInfo

        /// <summary>
        /// 
        /// </summary>
        /// <param name="metadata"></param>
        /// <param name="memberInfo"></param>
        /// <param name="entityKey"></param>
        public EntityRecordInfo(EntityType metadata, IEnumerable<EdmMember> memberInfo, EntityKey entityKey, EntitySet entitySet)
            : base(TypeUsage.Create(metadata), memberInfo) {
            EntityUtil.CheckArgumentNull<EntityKey>(entityKey, "entityKey");
            EntityUtil.CheckArgumentNull(entitySet, "entitySet");

            _entityKey = entityKey;
            _entitySet = entitySet;
            ValidateEntityType(entitySet);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:15,代码来源:EntityRecordInfo.cs

示例14: RelationshipChange

 public RelationshipChange(EntityKey sourceKey, EntityKey targetKey, object source, object target, EntitySetBase entitySet, EntityState state)
 {
     _sourceKey = sourceKey;
     _targetKey = targetKey;
     _source = source;
     _target = target;
     _entitySet = entitySet;
     _state = state;
 }
开发者ID:uglybugger,项目名称:EntityFrameworkAuditor,代码行数:9,代码来源:RelationshipChange.cs

示例15: ManagementObjectsViewModel

 public ManagementObjectsViewModel()
 {
     using (var context = new MCDatabaseModelContainer())
     {
         var key = new EntityKey();
         context.ObjectStateManager.GetObjectStateEntry(key);
         Buildings = context.Buildings.ToList();
     }
 }
开发者ID:ReaderOfDream,项目名称:GitProjects,代码行数:9,代码来源:ManagementObjectsViewModel.cs


注:本文中的EntityKey类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。