Search Results

Search found 9916 results on 397 pages for 'entity component'.

Page 16/397 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Creating a castable entity class wrapper

    - by Tony
    Hi I need to have a wrapper class that exposes some properties of my entity class called ProfileEntity. I tried doing it by deriving from this entity and then creating properties that return specific entity properties, but it says I cannot cast from ProfileEntity to ProfileEntityWrapper. When I try to put the return values of a method that returns a 'ProfileEntity' into the wrapper I get the above error. How do I create such a wrapper class that is castable? Example class ProfileEntityWrapper : ProfileEntity { public string Name { get { return this.ProfileEntityName; } } public class Someclass { public ProfileEntity SomeMethod() { return ProfileEntity; // example of method returning this object } } public class SomeOtherlClass { SomeClass sc = new SomeClass(); public void DoSomething() { ProfileEntityWrapper ew = (ProfileEntityWrapper)sc.SomeMethod(); // Cannot do this cast!!! } }

    Read the article

  • Paint java GUI component to image file

    - by Simon
    Let's say I have JButton test = new JButton("Test Button"); and I want to draw the button into an image object and save it to a file. I tried this: BufferedImage b = new BufferedImage(500, 500, BufferedImage.TYPE_INT_ARGB); test.paint(b.createGraphics()); File output = new File("C:\\screenie.png"); try { ImageIO.write(b, "png", output); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } This code produced an empty 500x500 PNG-file. Does anyone know how I can draw the GUI component to an image file?

    Read the article

  • What is the proper way to create a recursive entity in the Entity Framework?

    - by Orion Adrian
    I'm currently using VS 2010 RC, and I'm trying to create a model that contains a recursive self-referencing entity. Currently when I import the entity from the model I get an error indicating that the parent property cannot be part of the association because it's set to 'Computed' or 'Identity', though I'm not sure why it does it that way. I've been hand-editing the file to get around that error, but then the model simply doesn't work. What is the proper way to get recursive entities to work in the Entity Framework. CREATE TABLE [dbo].[Appointments]( [AppointmentId] [int] IDENTITY(1,1) NOT NULL, [Description] [nvarchar](1024) NULL, [Start] [datetime] NOT NULL, [End] [datetime] NOT NULL, [Username] [varchar](50) NOT NULL, [RecurrenceRule] [nvarchar](1024) NULL, [RecurrenceState] [varchar](20) NULL, [RecurrenceParentId] [int] NULL, [Annotations] [nvarchar](50) NULL, [Application] [nvarchar](100) NOT NULL, CONSTRAINT [PK_Appointments] PRIMARY KEY CLUSTERED ( [AppointmentId] ASC ) ) GO ALTER TABLE [dbo].[Appointments] WITH CHECK ADD CONSTRAINT [FK_Appointments_ParentAppointments] FOREIGN KEY([RecurrenceParentId]) REFERENCES [dbo].[Appointments] ([AppointmentId]) GO ALTER TABLE [dbo].[Appointments] CHECK CONSTRAINT [FK_Appointments_ParentAppointments] GO

    Read the article

  • How do I delete a child entity from a parent collection with Entity Framework 4?

    - by simonjreid
    I'm using Entity Framework 4 and have a one-to-many relationship between a parent and child entity. I'm trying to delete a child using the parent repository by removing it from the parent's children collection: public virtual void RemoveChild(Child child) { children.Remove(child); } When I try to save the changes I get the following error: A relationship from the 'ParentChild' AssociationSet is in the 'Deleted' state. Given multiplicity constraints, a corresponding 'Child' must also in the 'Deleted' state. Surely I don't have to delete the child entity explicitly using a child repository!

    Read the article

  • Entity Framework vs LINQ to SQL

    - by Chris Roberts
    Now that .NET v3.5 SP1 has been released (along with VS2008 SP1), we now have access to the .NET entity framework. My question is this. When trying to decide between using the Entity Framework and LINQ to SQL as an ORM, what's the difference? The way I understand it, the Entity Framework (when used with LINQ to Entities) is a 'big brother' to LINQ to SQL? If this is the case - what advantages does it have? What can it do that LINQ to SQL can't do on its own?

    Read the article

  • How to assign default values and define unique keys in Entity Framework 4 Designer

    - by csharpnoob
    Hello, I've had a look at the Entity Framework 4. While generating code for the SQL Server 2008 I came to the point where I want to define some default values for some fields. how to define in the designer for a Created DateTime Field the DateTime.Now default value? - Error 54: Default value (DateTime.Now) is not valid for DateTime. The value must be in the form 'yyyy-MM-dd HH:mm:ss.fffZ' how to make for code generation a string Field unique. Like E-Mail or Username can exists only once in the table. I've search alot in the internet and also checked my books Pro Entity Framework 4.0 and Programming Entity Framework. But none of them seems to come up with the default value issue, or using sql commands as default values for database generation. Another thing is, how to prevent on database generation always from droping tables? Instead i want to append non existing fields and keep the data. Thanks for any suggestions.

    Read the article

  • Entity Framework: Data Centric vs. Object Centric

    - by Eric J.
    I'm having a look at Entity Framework and everything I'm reading takes a data centric approach to explaining EF. By that I mean that the fundamental relationships of the system are first defined in the database and objects are generated that reflect those relationships. Examples Quickstart (Entity Framework) Using Entity Framework entities as business objects? The EF documentation implies that it's not necessary to start from the database layer, e.g. Developers can work with a consistent application object model that can be mapped to various storage schemas When designing a new system (simplified version), I tend to first create a class model, then generate business objects from the model, code business layer stuff that can't be generated, and then worry about persistence (or rather work with a DBA and let him worry about the most efficient persistence strategy). That object centric approach is well supported by ORM technologies such as (n)Hibernate. Is there a reasonable path to an object centric approach with EF? Will I be swimming upstream going that route? Any good starting points?

    Read the article

  • Selecting Entity Data Model Laguage -- Visual C# source file generated even when i select VB

    - by Nickson
    Am adding an Entity Data Model to an ASP.NET website. When i Add New Item to the website and select ADO.NET Entity Data Model, am asked for the model name and language. I go a head and select Visual Basic as the language, the model is added and the site can compile with out any issues. however, the model it adds a ModelName.Designer.cs source file, instead of a ModelName.Designer.vb source file. am thinking this is strange as its happening with only one of my website. my other sites have .vb designer source file for their Entity Data Models. The site still compiles with out any errors but am afraid some thing is not right. any one experienced this?, is this normal behavior?

    Read the article

  • EF2: Is there a way to add an Entity to EntityCollection without having to load related Entity?

    - by mutex
    I can set an EntityReference on an entity without having to load the relevent entity as follows: this.CategoryReference.EntityKey = new EntityKey("MyEntities.CategorySet", "Id", 12); So I can set the Category for the entity I'm dealing with to whatever category has id 12 without having to hit the database. But is there a way to do this or something similar on an EntityCollection? So if I now have multiple categories instead of just one, I want to now do something like the following, though it doesn't work: // stand-in category var categoryStandIn = new Category { EntityKey = new EntityKey("MyEntities.CategorySet", "Id", 12) } this.Categories.Add(categoryStandIn);

    Read the article

  • Entity Framework ObjectContext Life-cycle

    - by Leonardo
    Hello, I'm developing a web application using asp.net 4.0 with Entity Framework. In my apllication I have a page DataEntry.aspx wich has 3 web user control.Each user control manage an entity and use a repository class to access data. The final user before save all the changes can add or remove entity in memory. My question is: how can i share the ObjectContext between the repositories? Basically I need a ObjectContext for the entire session working of DataEntry.aspx. How can I achive this? Thank you

    Read the article

  • how to populate an entity you have extended in the Entity Framework?

    - by user169867
    I have an entity in my EDMX that I've extended with a few fields in a partial class like this: public partial class Employee { public string JobName {get;set;} } These properties are for display only. In the above example say the entity has a JobTypeID property. I wish JobName to be populated w/ the name that belongs to that JobTypeID. Is there anyway to query the employee record in EF including the value for the JobName property w/o explicity assigning each field using select()? The reason I ask is that there are a lot of fields in the Employee entity so I'd like to be able to take advantage of something like: ctx.Employees.Where(e=>e.EmployeeID==employeeID).Single() ...add somehow fill in JobName too Is this possible?

    Read the article

  • Managing Large Database Entity Models

    - by ChiliYago
    I would like hear how other's are effectively (or not) working with the Visual Studio Entity Designer when many database tables exists. It seems to me that navigating the Designer is tough enough to find what you are looking for with just a few tables but how about a database with say 100 to 200 tables? When a table change is made at the database level how is the model updated? Does it overwrite any manual changes you have made to the model? How would you quickly find an entity in the designer to make a change or inspect a change? Seems unrealistic to be scrolling around looking for specific entity. Thanks for your feedback!

    Read the article

  • EF 4.x generated entity classes (POCO) and Map files

    - by JBeckton
    I have an MVC 4 app that I am working on and using the code first implementation except I cheated a bit and created my database first then generated my entity classes (poco) from my database using the EF power tools (reverse engineer). I guess you can say I did database first method but I have no edmx file just the context class and my entity classes (poco) I have a few projects in the works using MVC and EF with pocos but just the one project I used the tool to generate my pocos from the database. My question is about the mapping files that get created when I generate my pocos using the tool. What is the purpose of these Map files? I figured the map files are needed when generating the db from the model like with the true code first method, in my case where I am using a tool to generate my model from the database do the map files have any influence on how my app uses the entity classes?

    Read the article

  • Software Engineering Component Repository Tool

    - by user320480
    Hello, I'm working as a software engineer for a company. We are going to apply some software engineering standards in our development process. We need a tool which provides a repository for our peripheral products (functions, classes, libraries, ...) which is created during software development process for later use. The tool should provide some functionalities (e.g Name of the component, it's functionality, withing which projects it is used?, author, publication date, list of known bugs, user rating, comment, ...) and it's better to have a web-based interface. Does anybody know such a software?

    Read the article

  • Storing Entity Framework Entities in a Separate Assembly

    - by Anthony Trudeau
    The Entity Framework has been valuable to me since it came out, because it provided a convenient and powerful way to model against my data source in a consistent way.  The first versions had some deficiencies that for me mostly fell in the category of the tight coupling between the model and its resulting object classes (entities). Version 4 of the Entity Framework pretty much solves this with the support of T4 templates that allow you to implement your entities as self-tracking entities, plain old CLR objects (POCO), et al.  Doing this involves either specifying a new code generation template or implementing them yourselves.  Visual Studio 2010 ships with a self-tracking entities template and a POCO template is available from the Extension Manager.  (Extension Manager is very nice but it's very easy to waste a bunch of time exploring add-ins.  You've been warned.) In a current project I wanted to use POCO; however, I didn't want my entities in the same assembly as the context classes.  It would be nice if this was automatic, but since it isn't here are the simple steps to move them.  These steps detail moving the entity classes and not the context.  The context can be moved in the same way, but I don't see a compelling reason to physically separate the context from my model. Turn off code generation for the template.  To do this set the Custom Tool property for the entity template file to an empty string (the entity template file will be named something like MyModel.tt). Expand the tree for the entity template file and delete all of its items.  These are the items that were automatically generated when you added the template. Create a project for your entities (if you haven't already). Add an existing item and browse to your entity template file, but add it as a link (do not add it directly).  Adding it as a link will allow the model and the template to stay in sync, but the code generation will occur in the new assembly.

    Read the article

  • Game Components, Game Managers and Object Properties

    - by George Duckett
    I'm trying to get my head around component based entity design. My first step was to create various components that could be added to an object. For every component type i had a manager, which would call every component's update function, passing in things like keyboard state etc. as required. The next thing i did was remove the object, and just have each component with an Id. So an object is defined by components having the same Ids. Now, i'm thinking that i don't need a manager for all my components, for example i have a SizeComponent, which just has a Size property). As a result the SizeComponent doesn't have an update method, and the manager's update method does nothing. My first thought was to have an ObjectProperty class which components could query, instead of having them as properties of components. So an object would have a number of ObjectProperty and ObjectComponent. Components would have update logic that queries the object for properties. The manager would manage calling the component's update method. This seems like over-engineering to me, but i don't think i can get rid of the components, because i need a way for the managers to know what objects need what component logic to run (otherwise i'd just remove the component completely and push its update logic into the manager). Is this (having ObjectProperty, ObjectComponent and ComponentManager classes) over-engineering? What would be a good alternative?

    Read the article

  • Handling game logic events by behavior components

    - by chehob
    My question continues on topic discussed here I have tried implementing attribute/behavior design and here is a quick example demonstrating the issue. class HealthAttribute : public ActorAttribute { public: HealthAttribute( float val ) : mValue( val ) { } float Get( void ) const { return mValue; } void Set( float val ) { mValue = val; } private: float mValue; }; class HealthBehavior : public ActorBehavior { public: HealthBehavior( shared_ptr< HealthAttribute > health ) : pHealth( health ) { // Set OnDamage() to listen for game logic event "DamageEvent" } void OnDamage( IEventDataPtr pEventData ) { // Check DamageEvent target entity // ( compare my entity ID with event's target entity ID ) // If not my entity, do nothing // Else, modify health attribute with received DamageEvent data } protected: shared_ptr< HealthAttribute > pHealth; }; My question - is it possible to get rid of this annoying check for game logic events? In the current implementation when some entity must receive damage, game logic just fires off event that contains damage value and the entity id which should receive that damage. And all HealthBehaviors are subscribed to the DamageEvent type, which leads to any entity possesing HealthBehavior call OnDamage() even if he is not the addressee.

    Read the article

  • How to add dynamically a component in JSF2 during an Ajax request.

    - by Guillaume
    Hello, I am currently trying to dynamically add a new component to the JSF component tree during an ajax request. In fact I add a child to the UIViewRoot component in my AjaxBehaviorListener which is fired on server side during the ajax request process. The issue is that the new component is not rendered. It seems that this component is not taken into account in the render response phase. Could you help me on this issue ? Regards, Guillaume

    Read the article

  • How to use Nhibernate Validator + NHib component + ddl

    - by mynkow
    I just configured my NHibValidator. My NHibernate creates the DB schema. When I set MaxLenght="20" to some property of a class then in the database the length appears in the database column. I am doing this in the NHibValidator xml file. But the problem is that I have components and cannot figure out how to achieve this behaviour. The component is configured correctly in the Customer.hbm.xml file. EDIT: Well, I found that Hibernate Validator users had the same problem two years ago. http://opensource.atlassian.com/projects/hibernate/browse/HV-25 Is this an issue for NHibernate Validator or it is fixed. If it is working tell me how please. ----------------------------------------------------- public class Customer { public virtual string Name{get;set;} public virtual Contact Contacts{ get; } } ----------------------------------------------------- public class Contact { public virtual string Address{get;set;} } ----------------------------------------------------- <?xml version="1.0" encoding="utf-8" ?> <nhv-mapping xmlns="urn:nhibernate-validator-1.0" namespace="MyNamespace" assembly="MyAssembly"> <class name="Customer"> <property name="Name"> <length max="20"/> </property> <property name="Contacts"> <notNull/> <valid/> </property> </class> </nhv-mapping> ----------------------------------------------------- <?xml version="1.0" encoding="utf-8" ?> <nhv-mapping xmlns="urn:nhibernate-validator-1.0" namespace="MyNamespace" assembly="MyAssembly"> <class name="Contact"> <property name="Address"> <length max="50"/> <valid/> </property> </class> </nhv-mapping> -----------------------------------------------------

    Read the article

  • JSF 2 - clearing component attributes on page load?

    - by jamiebarrow
    Hi, The real question: Is there a way to clear certain attributes for all components on an initial page load? Background info: In my application, I have a JSF 2.0 frontend layer that speaks to a service layer (the service layer is made up of Spring beans that get injected to the managed beans). The service layer does its own validation, and I do the same validation in the frontend layer using my own validator classes to try and avoid code duplication somehow. These validator classes aren't JSF validators, they're just POJOs. I'm only doing validation on an action, so in the action method, I perform validation, and only if it's valid do I call through to the service layer. When I do my validation, I set the styleClass and title on the UIComponents using reflection (so if the UIComponent has the setStyleClass(:String) or setTitle(:String) methods, then I use them). This works nicely, and on a validation error I see a nicely styled text box with a popup containing the error message if I hover over it. However, since the component is bound to a Session Scoped Managed Bean, it seems that these attributes stick. So if I navigate away and come back to the same page, the styleClass and title are still in the error state. Is there a way to clear the styleClass and title attributes on each initial page load? Thanks, James P.S. I'm using the action method to validate because of some issues I had before with JSF 1.2 and it's validation methods, but can't remember why... so that's why I'm using the action method to validate.

    Read the article

  • Entity Framework SaveChanges error details

    - by Marek Karbarz
    When saving changes with SaveChanges on a data context is there a way to determine which Entity causes an error? For example, sometimes I'll forget to assign a date to a non-nullable date field and get "Invalid Date Range" error, but I get no information about which entity or which field it's caused by (I can usually track it down by painstakingly going through all my objects, but it's very time consuming). Stack trace is pretty useless as it only shows me an error at the SaveChanges call without any additional information as to where exactly it happened. Note that I'm not looking to solve any particular problem I have now, I would just like to know in general if there's a way to tell which entity/field is causing a problem. Quick sample of a stack trace as an example - in this case an error happened because CreatedOn date was not set on IAComment entity, however it's impossible to tell from this error/stack trace [SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.] System.Data.SqlTypes.SqlDateTime.FromTimeSpan(TimeSpan value) +2127345 System.Data.SqlTypes.SqlDateTime.FromDateTime(DateTime value) +232 System.Data.SqlClient.MetaType.FromDateTime(DateTime dateTime, Byte cb) +46 System.Data.SqlClient.TdsParser.WriteValue(Object value, MetaType type, Byte scale, Int32 actualLength, Int32 encodingByteSize, Int32 offset, TdsParserStateObject stateObj) +4997789 System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc) +6248 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +987 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +10 System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues) +8084396 System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) +267 [UpdateException: An error occurred while updating the entries. See the inner exception for details.] System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) +389 System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache) +163 System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) +609 IADAL.IAController.Save(IAHeader head) in C:\Projects\IA\IADAL\IAController.cs:61 IA.IAForm.saveForm(Boolean validate) in C:\Projects\IA\IA\IAForm.aspx.cs:198 IA.IAForm.advance_Click(Object sender, EventArgs e) in C:\Projects\IA\IA\IAForm.aspx.cs:287 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5019

    Read the article

  • Update primary key value using entity framework

    - by lemkepf
    I'm trying to update one value of a compound primary key from within the entity framework and I'm getting this error: "The property 'CustomerID' is part of the object's key information and cannot be modified. " Here is my code: Dim customer As Customer = (From c In db.Customer Where c.CustomerID = "xxx" AndAlso c.SiteKey = siteKey).FirstOrDefault customer.CustomerID = "fasdfasdf" db.SaveChanges() It seems too simple. Is it true you can't update a primary key within the entity framework? I can't find any documentation on the topic. Thanks!

    Read the article

  • MvcBuildViews true with Entity Framework in ASP.NET MVC 2

    - by Alper Ozcetin
    Hi everybody, In VS 2010, changing true in a MVC2 project's .csproj file causes an error if you are using Entity Framework. Could not load type 'System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider'. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config 129 I want to build views while I'm debugging, and I also want my project compile! Any ideas? Thanks.

    Read the article

  • Entity Data Model with Oracle

    - by Sridhar
    Hi, I'm using VS 2008 SP1. I want to create an edmx file using my existing database in Oracle 10g. I tried to add ADO.Net Entity Data Model item, but in the Entity Data Model Wizard, .NET Provider for Oracle does not show up. Can someone suggest a way to connect to existing Oracle database to generate the edmx file? Thanks.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >