model

asp.net mvc database model dynamic Properties

Hi All, Im just wondering how you go about creating dynamic properties on entities that generated from a database generated model. For example I have a UserInformation table. In that table it has basic information on the user (well derr) like user name, address details etc etc. I want to add a readonly property that concatenates the use...

NHibernate slow startup, conditional loading of HBMs and "Association references unmapped class"

Background We have several projects / applications running off the same model. They all have their own unique entities / tables, but also share 1 specific, common entity / table. I.e. Entities required by application A, will never be required by application B, except for the common table, and vice versa. Now the common table has relatio...

Using the Description Metadata Attribute in ASP.NET MVC

I am working on a VB.NET project which is using ASP.NET MVC 2. I am taking advantage of the ability to add validation and other attributes to the metadata in my model. For example, I have added attributes such as <DisplayName("Full Name")> to the properties in my model and am rendering these using the Html.LabelFor () extension method....

MVC Default Model Binder - Bind a Multiselect Dropdown to an IList<T>

I'm using MVC 2.0 in an ASP.NET application using NHibernate. I have a working View, Controller and data access layer using NHibernate that is able to display and save an entity with a relationship to another mapped entity: Person -- > Location It's using the HTML helper HTML.DropDownListFor() to display a list of all Locations. The u...

Limit access by Controller or by Model?

I'm just starting to sketch up the base of a web-based system, and I would like the admin to have the possibility to limit access either by Controller or by Model. My problem is, I can't decide which one (or both?) of them I should go with. Any ideas? Pros/Cons? First I was leaning towards doing it in the Controllers, seeing as they "co...

.NET/MVC2 data caching using Entity Data Models

I am having a strange caching problem and I believe it might be related to the fact that I am using a Entity Data Model as my data source. The problem is that I can update the database directly and it doesn't reflect on the actual site until I republish the project. The data does display properly when viewing the project locally. The o...

Should model objects be flexible

Hello, [Sorry but work is proprietary so I cannot give details of objects] I am working on a Java application with a colleague. I am doing the client side and he is writing the server code. The application displays a table of X objects. The columns of the table show some of X's attributes. In addition we have a column that shows a cou...

MVC: Where should I format data?

Hi, I get data from Model (an array with data) and I need to display with a specific format. I need to iterate over the array, format the data and then display it. Where should I format data to display? In Model, Controller or View? Thank you. ...

Use Automapper for mapping big domain models to database objects

I would like to use Automapper to map my model objects to database objects. Let say database object is over 30 fields and I want map 10 out of 20 properties from my model. To make it more complex I need to map different properties when I update record than when I insert new record to database. The solution I'm using is to create 2 gener...

WPF Application framework is binding to the model ?

Hello; today I examinted WAP from codeplex a bit and saw this: BookListView.xaml: <ListView ItemsSource="{Binding Books}" SelectedItem="{Binding SelectedBook}" SelectionChanged="ListViewSelectionChanged"> <ListView.View> <GridView> <GridViewColumn DisplayMemberBinding=...

[Required] attribute dependent on another field

Hi, In a model of my ASP.NET MVC application I would like validate a textbox as required only if a specific checkbox is checked. Something like public bool retired {get, set}; [RequiredIf("retired",true)] public string retirementAge {get, set}; How can I do that? Thank you. ...

I cannot find template ADO.NET Entity Data Model in VS2010

Greetings, In VS2010, I cannot find the template ADO.NET Entity Data Model from the Data section. I was doing: 1. create a silverlight(version 4th) project with a WebSite 2. right click the web project, Add -> New Item -> Data Section(actually, I tried every one) But i cannot find it!! It's weird! Then, 1. I tried to reset my VS templ...

rails: stow away long method in model

Hello, I have this method (50+ lines) in one of my models, I prefer not having to scroll so much and not losing my cursor sometimes because of its taking up so much space. I wonder if I can put it away in a separate file and sort of include it in the model instead. Thanks! ...

How to user "and" condition in cakephp model?

Hello, I am using this to validate a form field $valid = $this->isUnique(array($fieldName1 => $data, $fieldName2 => 'Y')); executing this the query is coming like this: SELECT COUNT(*) AS count FROM users AS User WHERE ((User.emailid = ('[email protected]')) OR (User.isdeleted = 'Y')) I just need to change that "OR" to "AND". Pl...

Why I can't change the data of another model in CakePHP

Hi, I have a one-to-one relation between an Account and a User table, I'm trying to do all the pre-processing in the beforeSave of the account model, but it seems like i can only change the values of $this->data['Account'][...] and not $this->data['User'][...], why is so? function beforeSave() { // Check if this is a create or updat...

How do I correctly add this model to a method?

This is a method that used to be in the controller and I think it makes more sense to make it a method to the Contact model: def colleagues company = Company.find(self.company_id) contacts = company.contacts.collect(&:full_name) contacts.each do |contact| colleagues = contacts.reject{ |c| c==contact } end ...

Do you know any editor, that can handle the Xcode xcclassmodel-files ?

Any time i do a class-diagramm with the Xcode-internal solution, any inheritance-link is missing. But anytime another.. it is not even the same link, that is missing. so, has anyone an idea, how to edit the files manually ? ...

Identify which action is being called inside a model. Ruby on Rails

How do I come to know whether a create or any other action has been called from inside a model. Basically I am doing database logging and want to track whether a create or other actions are being performed. For doing the logging part I am using the concept of ActiveRecord::Observer. But there I am not able to find out whether the user i...

ASP.NET mvc linq 2 SQL model : where is the business logic?

I'm building a first MVC app in ASP.NET and I'm using link2SQL model to work with data. All tutorials on the microsoft site let you write LINQ code in the controller to get data and pass it to the view, like this: Function Index() As ActionResult Dim datacontext As New ErrorVaultDataContext Dim questions = From q In da...

grails domain class validator + set unique constraint according to field values ?

Hi, Is there a way to write a custom validator that will perform different validations according to field values? For example class myModel{ A a; B b; String prop static belongsTo:[m:myModel] constraints{ prop(validator:{ val,obj-> if (obj.a== null){ unique:[b,prop] ...