Search Results

Search found 43366 results on 1735 pages for 'entity attribute value'.

Page 8/1735 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • UDF call in entity framework is cached

    - by Fred Yang
    I am doing a test after reading an article http://blogs.msdn.com/alexj/archive/2009/08/07/tip-30-how-to-use-a-custom-store-function.aspx about udf function called. When I use a function with objectContext.Entities.Where( t= udf(para1, para2) == 1), here the Entities is not ObjectQuery, but an ObjectSet, the first time I call the method, it runs correctly, if I reuse the objectContext,and run it again but with different para1, para2, then the previous parameter values still cached, and the result is same as previous one, which is wrong. The sql profiler shows that both query hit the database, but the t-sql is the same. Am I missing something? And the ObjectSet does not support .where(esql_string). How to get udf working with ObjectSet? Thanks Fred

    Read the article

  • Error reached after genereated entity framework classes by edmgen tool

    - by loviji
    Hello, First I read this question, but this knowledge did not help to solve my problems. In initial I've created edmx file by Visual Studio. Generated files with names: uqsModel.Designer.cs uqsModel.edmx This files are located on App_Code folder. And my web app work normally. In Web Config generated connectionstring automatically. <add name="uqsEntities" connectionString="metadata=res://*/App_Code.uqsModel.csdl|res://*/App_Code.uqsModel.ssdl|res://*/App_Code.uqsModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=aemloviji\sqlexpress;Initial Catalog=uqs;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" /></connectionStrings> Then I had to generate classes by the instrument edmgen tool(full generation mode). Generated new files with names: uqsModel.cs uqsModel.csdl uqsModel.msl uqsModel.ssdl uqsViews.cs it save new classed to the folder where edmx files located before, and remove existing edmx files. And when page redirrects to any web page server side code fails. And problem: Unable to load the specified metadata resource. Some idea, please.

    Read the article

  • Entity Framework - Optimistic Concurrency Issue

    - by Cranialsurge
    I have a windows service that runs every 10 seconds ... each time it runs, it takes some test data, modifies it and persists it to the database using the EntityFramework. However, on every second run, when I try to persist the change I get the following Optimistic Concurrency Exception:- Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries I know for a fact that there is nothing else writing to that DB but my service which updates records every 10 seconds. What could be causing the concurrency exception here ?

    Read the article

  • Unable to specify abstract classes in TPH hierarchy in Entity Framework 4

    - by Lee Atkinson
    Hi I have a TPH heirachy along the lines of: A-B-C-D A-B-C-E A-F-G-H A-F-G-I I have A as Abstract, and all the other classes are concrete with a single discriminator column. This works fine, but I want C and G to be abstract also. If I do that, and remove their discriminators from the mapping, I get error 3034 'Two entities with different keys are mapped to the same row'. I cannot see how this statement can be correct, so I assume it's a bug in some way. Is it possible to do the above? Lee

    Read the article

  • Entity Relationship Multiple 1:1's

    - by Evan
    I have an application where I have a generic object (table) called Hull. Each hull in the table is unique. I have another object that has three hulls, but they are specifically the Port_Hull, Center_Hull and Starboard_Hull. Rather than create a One to Many relationship, I was trying to create a one to one relationship for each one, but this results in numerous errors unless I make the relationship from Hull to Vessel one to many (which it is not). Any idea how I go about this, or should I abandon the concept and make the vessel to hull relationship one to many and deal with lists that always have three entries? p.s. Using uniqueidentifiers as many users can be adding records while disconnected. Hull Table HullID uniqueidentifier (primary key) plus bunch of hull data fields Vessel Table VesselID uniqueidentifier (primary key) MainHullID uniqueidentifier (tried as key and non-key) PortHullID uniqueidentifier StarboardHullID uniqueidentifier plus bunch of Vessel data fields

    Read the article

  • JQuery returns wrong value for IE Compatibility

    - by o-logn
    Hey , I'm using JQuery and there seems to be a problem when I run IE in compatibility mode (and generally any IE less than version 8). I'm trying to use attr("value") for a button control. In IE8, and other browsers, this works fine and the result of this code: alert($(this).attr("value")); is simply the value of set in the button attribute (e.g. Home, Settings, Help etc..) However, when this is run in IE compatibility view, I get the entire HTML as the output value: <SPAN class=ui-button-text>Home</SPAN> This causes my checks to fail. Is there a way to return just the Home section across all browsers? Thanks

    Read the article

  • override delete function in entity framework

    - by k0ni
    How can i make my own delete method to prevent that the data really gets deleted? i want to set a datetime field when it gets deleted insted of a normal delete. i read about overriding the submitchanges function, but i don't get it to work thanks

    Read the article

  • DeleteObject method is missing in Entity Framework 4.1

    - by bobetko
    This is driving me crazy. I am getting error that object doesn't contain definition for DeleteObject. Here is my line of code that produces an error: ctx.Tanks.DeleteObject(Tank); I tried to reference another object from another edmx file that my friend has created and then everything is fine, DeleteObject exists. I don't think I miss any references in my project. And project itself contains edmx file and I used DBContext to create POCOs. Any ideas?

    Read the article

  • Missing something with Entity Framework for .NET 3.5?

    - by AC
    Is it not possible to have EF create the necessary entities when I have two related tables linked with a FK in .NET3.5SP1? I see where the checkbox to support this is disabled but it is available in .NET4. I've got a DB that has only tables with relationships in it. I need to build a Silverlight app (SL4) that allows management of the data within this app. I can't use .NET4 on the server... only .NET3.5SP1 so FK relationship bit in EF4 isn't available to me. Looking to avoid building as much of the plumbing to get back to the DB from the SL4 app as possible...

    Read the article

  • Entity Framework 4 - Delete Object

    - by GibboK
    I have 3 Tables in my DataBase CmsMasterPages CmsMasterPagesAdvSlots (Pure Juction Table) CmsAdvSlots Here a Picture of my EDM: I need find out all objects CmsAdvSlot connected with a CmsMasterPage (it is working in my code posted belove), and DELETE the result (CmsAdvSlot) from the DataBase. My Problem is I am not able to DELETE this Objects when I found theme. Error: The object cannot be deleted because it was not found in the ObjectStateManager. int findMasterPageId = Convert.ToInt32(uxMasterPagesListSelector.SelectedValue); CmsMasterPage myMasterPage = context.CmsMasterPages.FirstOrDefault(x => x.MasterPageId == findMasterPageId); var resultAdvSlots = myMasterPage.CmsAdvSlots; // It is working until here foreach (var toDeleteAdv in resultAdvSlots) { context.DeleteObject(myMasterPage.CmsAdvSlots.Any()); // ERORR HERE!! context.SaveChanges(); } Any idea how to solve it? Thanks for your time! :-)

    Read the article

  • Entity Framework 4.0 GetChanges() equivalent

    - by Jonathan
    Hi In LINQ to SQL, you can override SubmitChanges and use the method this.GetChangeSet() to get all the inserts, updates and deletes so that you can make last minute changes before it is committed to the database. Can this be done in EF 4.0? I see there is a override for SaveChanges but I need to know the equivalent for GetChangeSet()

    Read the article

  • Entity Framework - Self Tracking Objects - how to reset client side?

    - by David
    I am using wcf with self tracking entity framework objects. On the client side i have bound an entity to an edit form (which has multiple textboxes and comboboxes). After the user hits Save, the entity is sent through wcf to the server wcf service which will attempt to save the entity. If there is a failure (say a network failure), I need to reset the current entity back to original values. How best can I do this client side? (I recognize with Self Tracking objects there is a property OriginalValues however that collection seems to have count=0) so not sure how to get the original values? Thanks-

    Read the article

  • Extracting the Date from a DateTime in Entity Framework 4 and LINQ

    - by Ken Cox [MVP]
    In my current ASP.NET 4 project, I’m displaying dates in a GridDateTimeColumn of Telerik’s ASP.NET Radgrid control. I don’t care about the time stuff, so my DataFormatString shows only the date bits: <telerik:GridDateTimeColumn FilterControlWidth="100px"   DataField="DateCreated" HeaderText="Created"    SortExpression="DateCreated" ReadOnly="True"    UniqueName="DateCreated" PickerType="DatePicker"    DataFormatString="{0:dd MMM yy}"> My problem was that I couldn’t get the built-in column filtering (it uses Telerik’s DatePicker control) to behave.  The DatePicker assumes that the time is 00:00:00 but the data would have times like 09:22:21. So, when you select a date and apply the EqualTo filter, you get no results. You would get results if all the time portions were 00:00:00. In essence, I wanted my Entity Framework query to give the DatePicker what it wanted… a Date without the Time portion. Fortunately, EF4 provides the TruncateTime  function. After you include Imports System.Data.Objects.EntityFunctions You’ll find that your EF queries will accept the TruncateTime function. Here’s my routine: Protected Sub RadGrid1_NeedDataSource _     (ByVal source As Object, _      ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) _     Handles RadGrid1.NeedDataSource     Dim ent As New OfficeBookDBEntities1     Dim TopBOMs = From t In ent.TopBom, i In ent.Items _                   Where t.BusActivityID = busActivityID _       And i.BusActivityID And t.ItemID = i.RecordID _       Order By t.DateUpdated Descending _       Select New With {.TopBomID = t.TopBomID, .ItemID = t.ItemID, _                        .PartNumber = i.PartNumber, _                        .Description = i.Description, .Notes = t.Notes, _                        .DateCreated = TruncateTime(t.DateCreated), _                        .DateUpdated = TruncateTime(t.DateUpdated)}     RadGrid1.DataSource = TopBOMs End Sub Now when I select March 14, 2011 on the DatePicker, the filter doesn’t stumble on time values that don’t make sense. Full Disclosure: Telerik gives me (and other developer MVPs) free copies of their suite.

    Read the article

  • Entity Framework 4.0: Creating objects of correct type when using lazy loading

    - by DigiMortal
    In my posting about Entity Framework 4.0 and POCOs I introduced lazy loading in EF applications. EF uses proxy classes for lazy loading and this means we have new types in that come and go dynamically in runtime. We don’t have these types available when we write code but we cannot forget that EF may expect us to use dynamically generated types. In this posting I will give you simple hint how to use correct types in your code. The background of lazy loading and proxy classes As a first thing I will explain you in short what is proxy class. Business classes when designed correctly have no knowledge about their birth and death – they don’t know how they are created and they don’t know how their data is persisted. This is the responsibility of object runtime. When we use lazy loading we need a little bit different classes that know how to load data for properties when code accesses the property first time. As we cannot add this functionality to our business classes (they may be stored through more than one data access technology or by more than one Data Access Layer (DAL)) we create proxy classes that extend our business classes. If we have class called Product and product has lazy loaded property called Customer then we need proxy class, let’s say ProductProxy, that has same public signature as Product so we can use it INSTEAD OF product in our code. ProductProxy overrides Customer property. If customer is not asked then customer is null. But if we ask for Customer property then overridden property of ProductProxy loads it from database. This is how lazy loading works. Problem – two types for same thing As lazy loading may introduce dynamically generated proxy types we don’t know in our application code which type is returned. We cannot be sure that we have Product not ProductProxy returned. This leads us to the following question: how can we create Product of correct type if we don’t know the correct type? In EF solution is simple. Solution – use factory methods If you are using repositories and you are not using factories (imho it is pretty pointless with mapper) you can add factory methods to your EF based repositories. Take a look at this class. public class Event {     public int ID { get; set; }     public string Title { get; set; }     public string Location { get; set; }     public virtual Party Organizer { get; set; }     public DateTime Date { get; set; } } We have virtual member called Organizer. This property is virtual because we want to use lazy loading on this class so Organizer is loaded only when we ask it. EF provides us with method called CreateObject<T>(). CreateObject<T>() is member of ObjectContext class and it creates the object based on given type. In runtime proxy type for Event is created for us automatically and when we call CreateObject<T>() for Event it returns as object of Event proxy type. The factory method for events repository is as follows. public Event CreateEvent() {     var evt = _context.CreateObject<Event>();     return evt; } And we are done. Instead of creating factory classes we created factory methods that guarantee that created objects are of correct type. Conclusion Although lazy loading introduces some new objects we cannot use at design time because they live only in runtime we can write code without worrying about exact implementation type of object. This holds true until we have clean code and we don’t make any decisions based on object type. EF4.0 provides us with very simple factory method that create and return objects of correct type. All we had to do was adding factory methods to our repositories.

    Read the article

  • Is it possible to auto update only selected properties on an existent entity object without touching the others

    - by LaserBeak
    Say I have a bunch of boolean properties on my entity class public bool isActive etc. Values which will be manipulated by setting check boxes in a web application. I will ONLY be posting back the one changed name/value pair and the primary key at a time, say { isActive : true , NewsPageID: 34 } and the default model binder will create a NewsPage object with only those two properties set. Now if I run the below code it will not only update the values for the properties that have been set on the NewsPage object created by the model binder but of course also attempt to null all the other non set values for the existent entity object because they are not set on NewsPage object created by the model binder. Is it possible to somehow tell entity framework not to look at the properties that are set to null and attempt to persist those changes back to the retrieved entity object and hence database ? Perhaps there's some code I can write that will only utilize the non-null values and their property names on the NewsPage object created by model binder and only attempt to update those particular properties ? [HttpPost] public PartialViewResult SaveNews(NewsPage Np) { Np.ModifyDate = DateTime.Now; _db.NewsPages.Attach(Np); _db.ObjectStateManager.ChangeObjectState(Np, System.Data.EntityState.Modified); _db.SaveChanges(); _db.Dispose(); return PartialView("MonthNewsData"); } I can of course do something like below, but I have a feeling it's not the optimal solution. Especially considering that I have like 6 boolean properties that I need to set. [HttpPost] public PartialViewResult SaveNews(int NewsPageID, bool isActive, bool isOnFrontPage) { if (isActive != null) { //Get entity and update this property } if (isOnFontPage != null) { //Get entity and update this property } }

    Read the article

  • How to use batch rendering with an entity component system?

    - by Kiril
    I have an entity component system and a 2D rendering engine. Because I have a lot of repeating sprites (the entities are non-animated, the background is tile based) I would really like to use batch rendering to reduce calls to the drawing routine. What would be the best way to integrate this with an engtity system? I thought about creating and populating the sprite batche every frame update, but that will probably be very slow. A better way would be to add a reference to an entity's quad to the sprite batch at initialization, but that would mean that the entity factory has to be aware of the Rendering System or that the sprite batch has to be a component of some Cache entity. One case violates encapsulation pretty heavily, while the other forces a non-game object entity in the entity system, which I am not sure I like a lot. As for engine, I am using Love2D (Love2D website) and FEZ ( FEZ website) as entity system(so everything is in Lua). I am more interested in a generic pattern of how to properly implement that rather than a language/library specific solution. Thanks in advance!

    Read the article

  • Loading Entities Dynamically with Entity Framework

    - by Ricardo Peres
    Sometimes we may be faced with the need to load entities dynamically, that is, knowing their Type and the value(s) for the property(ies) representing the primary key. One way to achieve this is by using the following extension methods for ObjectContext (which can be obtained from a DbContext, of course): 1: public static class ObjectContextExtensions 2: { 3: public static Object Load(this ObjectContext ctx, Type type, params Object [] ids) 4: { 5: Object p = null; 6:  7: EntityType ospaceType = ctx.MetadataWorkspace.GetItems<EntityType>(DataSpace.OSpace).SingleOrDefault(x => x.FullName == type.FullName); 8:  9: List<String> idProperties = ospaceType.KeyMembers.Select(k => k.Name).ToList(); 10:  11: List<EntityKeyMember> members = new List<EntityKeyMember>(); 12:  13: EntitySetBase collection = ctx.MetadataWorkspace.GetEntityContainer(ctx.DefaultContainerName, DataSpace.CSpace).BaseEntitySets.Where(x => x.ElementType.FullName == type.FullName).Single(); 14:  15: for (Int32 i = 0; i < ids.Length; ++i) 16: { 17: members.Add(new EntityKeyMember(idProperties[i], ids[i])); 18: } 19:  20: EntityKey key = new EntityKey(String.Concat(ctx.DefaultContainerName, ".", collection.Name), members); 21:  22: if (ctx.TryGetObjectByKey(key, out p) == true) 23: { 24: return (p); 25: } 26:  27: return (p); 28: } 29:  30: public static T Load<T>(this ObjectContext ctx, params Object[] ids) 31: { 32: return ((T)Load(ctx, typeof(T), ids)); 33: } 34: } This will work with both single-property primary keys or with multiple, but you will have to supply each of the corresponding values in the appropriate order. Hope you find this useful!

    Read the article

  • Executing logic before save or validation with EF Code-First Models

    - by Ryan Norbauer
    I'm still getting accustomed to EF Code First, having spent years working with the Ruby ORM, ActiveRecord. ActiveRecord used to have all sorts of callbacks like before_validation and before_save, where it was possible to modify the object before it would be sent off to the data layer. I am wondering if there is an equivalent technique in EF Code First object modeling. I know how to set object members at the time of instantiation, of course, (to set default values and so forth) but sometimes you need to intervene at different moments in the object lifecycle. To use a slightly contrived example, say I have a join table linking Authors and Plays, represented with a corresponding Authoring object: public class Authoring { public int ID { get; set; } [Required] public int Position { get; set; } [Required] public virtual Play Play { get; set; } [Required] public virtual Author Author { get; set; } } where Position represents a zero-indexed ordering of the Authors associated to a given Play. (You might have a single "South Pacific" Play with two authors: a "Rodgers" author with a Position 0 and a "Hammerstein" author with a Position 1.) Let's say I wanted to create a method that, before saving away an Authoring record, it checked to see if there were any existing authors for the Play to which it was associated. If no, it set the Position to 0. If yes, it would find set the Position of the highest value associated with that Play and increment by one. Where would I implement such logic within an EF code first model layer? And, in other cases, what if I wanted to massage data in code before it is checked for validation errors? Basically, I'm looking for an equivalent to the Rails lifecycle hooks mentioned above, or some way to fake it at least. :)

    Read the article

  • Rebuilding lazily-built attribute when an underlying attribute changes in Moose

    - by friedo
    I've got a Moose class with a lazy_build attribute. The value of that attribute is a function of another (non-lazy) attribute. Suppose somebody instantiates the class with a value of 42 for the required attribute. Then they request the lazy attribute, which is calculated as a function of 42. Then, they have the nerve to change the first attribute! The lazy one has already been built, so the builder will not get called again, and the lazy attribute is now out-of-date. I have a solution now where I maintain a "dirty" flag on the required attribute, and an accessor on the lazy one checks the dirty flag and rebuilds it if needed. However, this seems like a lot of work. Is there a way to handle this within Moose, e.g. using traits?

    Read the article

  • Effective way to check if an Entity/Player enters a region/trigger

    - by Chris
    I was wondering how multiplayer games detect if you enter a special region. Let's assume there is a huge map that is so big that simply checking it would become a huge performance issue. I've seen bukkit (a modding API for Minecraft servers) firing an Event on every single move. I don't think that larger games do the same because even if you have only a few coordinates you are interested in, you have to loop through a few trigger zone to see if the player is inside your region - for every player. This seems like an extremely CPU-intense operation to me even though I've never developed something like that. Is there a special algorithm that is used by larger games to accomplish this? The only thing I could imagine is to split up the world into multiple parts and to register the event not on the movement itself but on all the parts that are covered by your area and only check for areas that are registered in the current part. And another thing I would like to know: How could you detect when someone must have entered a trigger but you never saw him directly in it since his client only sent you an move packet shortly before entering and after leaving the trigger area. Drawing a line and calculate all colliding parts seems rather CPU intensive if you have to perform it every time.

    Read the article

  • Entity Framework looking for wrong column

    - by m.edmondson
    I'm brand new to the Entity Framework and trying to learn all it can offer. I'm currently working my way through the MVC Music Store tutorial which includes the following code: public ActionResult Browse(string genre) { // Retrieve Genre and its Associated Albums from database var genreModel = storeDB.Genres.Include("Albums") .Single(g => g.Name == genre); return View(genreModel); } as I'm working in VB I converted it like so: Function Browse(ByVal genre As String) As ActionResult 'Retrieve Genre and its Associated Albums from database Dim genreModel = storeDB.Genres.Include("Albums"). _ Single(Function(g) g.Name = genre) Return(View(genreModel)) End Function The problem is I'm getting the following exception: Invalid column name 'GenreGenreId'. Which I know is true, but I can't for the life of my work out where it's getting 'GenreGenreId' from. Probably a basic question but I'll appreciate any help in the right direction. As per requested here is the source for my classes: Album.vb Public Class Album Private _title As String Private _genre As Genre Private _AlbumId As Int32 Private _GenreId As Int32 Private _ArtistId As Int32 Private _Price As Decimal Private _AlbumArtUrl As String Public Property Title As String Get Return _title End Get Set(ByVal value As String) _title = value End Set End Property Public Property AlbumId As Int16 Get Return _AlbumId End Get Set(ByVal value As Int16) _AlbumId = value End Set End Property Public Property GenreId As Int16 Get Return _GenreId End Get Set(ByVal value As Int16) _GenreId = value End Set End Property Public Property ArtistId As Int16 Get Return _ArtistId End Get Set(ByVal value As Int16) _ArtistId = value End Set End Property Public Property AlbumArtUrl As String Get Return _AlbumArtUrl End Get Set(ByVal value As String) _AlbumArtUrl = value End Set End Property Public Property Price As Decimal Get Return _Price End Get Set(ByVal value As Decimal) _Price = value End Set End Property Public Property Genre As Genre Get Return _genre End Get Set(ByVal value As Genre) _genre = value End Set End Property End Class Genre.vb Public Class Genre Dim _genreId As Int32 Dim _Name As String Dim _Description As String Dim _Albums As List(Of Album) Public Property GenreId As Int32 Get Return _genreId End Get Set(ByVal value As Int32) _genreId = value End Set End Property Public Property Name As String Get Return _Name End Get Set(ByVal value As String) _Name = value End Set End Property Public Property Description As String Get Return _Description End Get Set(ByVal value As String) _Description = value End Set End Property Public Property Albums As List(Of Album) Get Return _Albums End Get Set(ByVal value As List(Of Album)) _Albums = value End Set End Property End Class MusicStoreEntities.vb Imports System.Data.Entity Namespace MvcApplication1 Public Class MusicStoreEntities Inherits DbContext Public Property Albums As DbSet(Of Album) Public Property Genres As DbSet(Of Genre) End Class End Namespace

    Read the article

  • How can I resolve component types in a way that supports adding new types relatively easily?

    - by John
    I am trying to build an Entity Component System for an interactive application developed using C++ and OpenGL. My question is quite simple. In my GameObject class I have a collection of Components. I can add and retrieve components. class GameObject: public Object { public: GameObject(std::string objectName); ~GameObject(void); Component * AddComponent(std::string name); Component * AddComponent(Component componentType); Component * GetComponent (std::string TypeName); Component * GetComponent (<Component Type Here>); private: std::map<std::string,Component*> m_components; }; I will have a collection of components that inherit from the base Components class. So if I have a meshRenderer component and would like to do the following GameObject * warship = new GameObject("myLovelyWarship"); MeshRenderer * meshRenderer = warship->AddComponent(MeshRenderer); or possibly MeshRenderer * meshRenderer = warship->AddComponent("MeshRenderer"); I could be make a Component Factory like this: class ComponentFactory { public: static Component * CreateComponent(const std::string &compTyp) { if(compTyp == "MeshRenderer") return new MeshRenderer; if(compTyp == "Collider") return new Collider; return NULL; } }; However, I feel like I should not have to keep updating the Component Factory every time I want to create a new custom Component but it is an option. Is there a more proper way to add and retrieve these components? Is standard templates another solution?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >