public virtual DateTime CreatedDate {get; set;}
public virtual string CreatedBy { get; set; }
public virtual DateTime UpdatedDate { get; set; }
public virtual string UpdatedBy { get; set; }
I've implemented a EventListener (IPreUpdateEventListener, IPreInsertEventListener) so that I can fill these properties before inserting/updating my entity.I do not load my entity just before saving cause I've got all my fields in a view (id, version). The only thing I would like to avoid to put in hidden fields (of my view) are CreatedDate and CreateBy.Since I fill these fields only once, when the entity is created the first time, I was wondering if there's a way to exclude them when I update (only update) my entitiy?!
But, name may not have changed, it may only be a change to the content textbox.
The problem is that entity framework treats Name as changed just because I've set it's value, regardless of whether I've set exactly the same value or not.
Ideally, I would like EF to only mark things as changed if they genuinely have changed.
I have created a .edmx for the northwind database. When I run the following statement, the correct number of detail records are retrieved and I can access the detail fields, but how do I access the order header record to view OrderDate, ShipAddress, etc...?
C#, ASP.NET MVC, SQL Server 2008 ( Same version & SP level), Linq-To-SQL ORM
I'm trying to diagnose an exception I'm receiving:
"Specified cast is not valid." at System.Data.Linq.IdentityManager.StandardIdentityManager.SingleKeyManager2.TryCreateKeyFromValues(Object[] values, V& v) at System.Data.Linq.IdentityManager.StandardIdentityManager.IdentityCache2.Find(Object[] keyValues) at System.Data.Linq.IdentityManager.StandardIdentityManager.Find(MetaType type, Object[] keyValues) at System.Data.Linq.CommonDataServices.GetCachedObject(MetaType type, Object[] keyValues) at System.Data.Linq.ChangeProcessor.GetOtherItem(MetaAssociation assoc, Object instance) at System.Data.Linq.ChangeProcessor.BuildEdgeMaps() at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode) at System.Data.Linq.DataContext.SubmitChanges() at Repository.Save() at etc....
The problem is that this is occurring only on our servers, not on our local development boxes. I've tracked it down to a single property we're modifying:
event.SalesForceId = "701Q0000000AOTIIA4";
If I comment out that line, everything works fine.
I've tried:
1 ) waxing all of the code on the server and redeploying. Same issue. 2 ) Pulling down a copy of the server DB and trying it locally. Works fine. 3 ) Trying another IIS environment we have setup on the same box. Same issue. 4 ) Physically comparing ( using AdeptSQL ) both local and remote schemas. No differences. 5 ) Verifying the datatypes of both columns ( local and remote ) are the same. Also, this column is a FK to another table. I verified that both are of the same data type, down to the collation.
The server is Windows Server 2008 and the local box is Windows 7 x64. Both have all important updates setup.
The only thing I can think of is perhaps since the database and web server are on different boxes that could be an issue? Otherwise, I'm completely stumped.
I have an EDM, it includes the entities extension and history. My goal is to use history to keep track of all the changes made to extension entity. For example, if extension with ID 223 has its property 'Name_Display' changed - I want the history entity to record this.
I'm using ASP.NET with VB.NET. Where in my code do I put the hook to say, "update the history entity" and what should that hook look like?
On EDITION form I have only fields: 'title' and 'message' (without field 'link'), but for 'link' is still triggered validation. How can I exclude 'link' from validation in action. I have tried:
[Code]....
But this doesn't work. I still see: "The link field is required.". What is the solution ?
I have a sql data souce that returns several columns of data, and they are displayed in a DetailsView on a pretty simple vb.net page. I'm stuggling with one field though for the details view.
It's a template field, and if ClientType=1 (this value is determined else where on the page), then the label in the template field should have Text='<%# Bind("ClientName") %>', but if the ClientType = 0, then the label in the template field should have Text='<%# Bind("ClientTemporaryName") %>'
How do I tell the details view to set the text for ClientName to one or the other?
I have a relatively complex dataset (numerous tables, some with multiple records) generated from reading in an XML file. I need to connect said dataset fields to an ASP form. At the moment I'm assigning them manually, like so in the pageload:
I did some looking into binding the textboxes (and dropdownlists, and checkboxes, and and and...) directly, but it seemed to be too many formats to use.
So this works fine, but as the number of fields increases, those load and unload lists are going to get unwieldy.
I am working on Crystal Reports 8.5 and SQL Server 2000 as backend. I have a stored procedure which has been added to the Crystal Report. So that fields are visible in the Fields object section from where i can drag and drop the fields on the report and display it. But now as they want more fields i have written two select statements for displaying required fields. But these newly added fields are not visible in the Fields object section in the Crystal Reports. I have done verify database, removed and again attached the SP but the problem is not solved.
getting data from multiple Entities models into an MVC controller. Most of the examples I have seen for using EF in an MVC2 app only use a single entitiy.
I have just started using MVC2 in C# using the Entity Framework models (CIOps.model) created from an SQL database. I can create the controller and views using single tables of the model in MVC2, but I just cannot get my head around how to get data from multiple entity tables into the controller (similar to joins in T-SQL). I have included an example below of the controller code that works with a single entity table, tbl_tours (tbl_tour in DB).
Could someone please illustrate how this code would be changed to include additional columns from FK tables in addition to tbl_tours columns. E.g. the clients name from the tbl_clients, the coordinators name from the tbl_employees, and costs from tbl_costs entities? Is it possible to do this directly using the EF model entities/classes that are already created and not use LINQ, POCO, Repositories, etc.? The FK relationships are already in the EF models. I have included the whole controller code, but I just need a few examples of how to join the multiple entities, not rewrite every CRUD function function in the controller. I think this will get me over the hump in using EF in an MVC2 App. Also ignore the fact I am using the home controller, this will change in the application.
string pattern = "<(.| )+?>"; System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Reg(pattern); string result = ""; result = regEx.Replace(htmlText, "");
In this "htmlText" will have some html code which also contains break tags. Right now its replacing all the html tags, but I want to leave break tag and replace the rest.
Isn't the Bind attribute, preferable the Exclude parameter, define any properties that will be excluded from any form update? If so, why does the ModelState is not valid when I do this?
I'm attempting to serialize an object but I would like to exclude one of the objects inside it. I've tried [NonSerialized] and it is still attempting to serialize it when I call XmlSerialize on a Cart object.
[Serializable] [XmlRoot("Cart")] public class Cart : ICart { // Public Properties [DefaultValue("")] public string ID { set; get; } [XmlIgnore()] [NonSerialized] public CartSerializer Serializer = new CartSerializer(this); }
On my MasterPage I use UpdatePanel to update whole ContentPlaceHolder. Example of code you can find below. All content pages work fine with this MasterPage except one. This page is very complex. I noticed that when I disable UpdatePanel in my MasterPage this problematic page works fine. Question: is it possible to exclude something from UpdatePanel - in my example whole page but only this one?
I have a VM which contains a DTO inside it and DTO again contains properties.
it is like this :
[Code]....
Now i attach this VM to a View and expect the contactPersonVM as parameter. I am using same View for both Create and Edit. When in Create Mode i don't want SysId property to be attached as it is not required in create Mode.
This is the code for create action:
[Code]....
Though i have Excluded SysId from Binding but its still giving me ModelState error of "SysId is required". If i attach a Bind attribute directly to ContactPerson DTO then it works but then it applies for both Create and Edit. I want Bind attribute to be only for Create Action.
In MVC2, why the BindAttribute Exclude doesn't work?
I have two Controllers that calls the same model object on submission, however, one page must be exempted from the model validation but below doesn't work.
Employee.vb Imports System.ComponentModel.DataAnnotations Public Class Employee Private _Email As String <Required(ErrorMessage:="Enter Email value.")> _
I get an cast exception when i am trying to insert an entity in Entity Framework (using code-first). From this code :
public virtual T Insert(T entity) { return Context.Set<T>().Add(entity); }
The cast exception is like "impossible to cast ...Collection'1(Entity) to type (Entity)" I can't figure out why. I am pretty sure ive done everything right. Post entity
public class Post { public long PostId { get; private set; } public DateTime date { get; set; } [Required] public string Subject { get; set; } public User User { get; set; } public Category Category { get; set; } [Required] public string Body { get; set; } public virtual ICollection<Tag> Tags { get; private set; } public Post() { Category = new Category(); if (Tags == null) Tags = new Collection<Tag>(); }................................
I am mapping a stored procedure to an entity by right clicking on the entity (in the .edmx) and selecting "Stored Procedure Mapping." This brings you to a Mapping Details - "Name of Entity" Window that allows you to select the insert, update, and delete stored procedures associated with the Entity. It also maps the stored procedure parameter to the Entity "Property" (Column).
I'm gettin an error "error 2042: Parameter Mapping specified is not valid." The cause of the error is fairly obvious, in the Insert stored procedure that has been selected, a 'CHAR' parameter is being mapped to an Int32 Entity Property. I altered the stored procedure parameter to match the entity, I deleted the stored procedure, readded, and reslected it as the Insert function. I also cleaned, validated, updated model from database. No matter what I do, the parameter list in the mapping details doesn't reflect the change to the stored procedure. It's stuck on a char --> int32 mapping, even though it has been changed, like it's buried deep in meta data some where.
In PDF.aspx, I create a pdf of a webpage. Because a new browser window opens here, the user is lost and the application will return to the login screen --> result: a pdf is created of the login screen.
My question: how can I know exclude the pdf.aspx webform from the FormsAuthentication and still remains safe
I would like to exclude one of model's property from the Html.EditorFor. I tried [HiddenInput(DisplayValue=false)] but it renders the property as an hidden input. This could potentially be a security problem. How can we completely exclude a field from Html.EditorFor?
I have placed a user control inside update panel after doing asynchronous postback of page associated js file of that user control is not working so that is there any method to exclude a control from updatepanel in another word i don't want to post that user control.
<asp:UpdatePanel ID="upPnlAnswerList" runat="server"> <ContentTemplate> // another code that required to placed inside updatepanel <div id="miancontainer" class="containerr" <klmsuc:Share ID="shareUserControl" runat="server" /> [code]...