model

Repository Pattern using LINQ To SQL without generated Models

I want to use my own Model classes in a repository pattern. I don't want to be dependent on the classes that LINQ to SQL generates. Is that viable? How do I handle the Where (and other selections when its a Func<MyModel, bool> but LINQ to SQL wants a Func<LinqToSqlModel, bool>? I've devised this, but I might be starting to over engineer...

What associations should I use to be able to sort search results by an associated model in a rails app?

Hi all, I'm currently writing an app that pulls all the tweets from twitter with links in them and puts them into our searchable database. Our database tables look like this: Tweets content tweet_id Links url title count User username user_image We'd like to be able to search through the tweet.content column for a s...

How do I bind a textbox to a Model parameter in a Strongly Typed View in Asp.Net MVC?

The only way I've seen this done in the tutorials I've looked at, they say to create a new .ascx and choose the option "create" for View Content. I want to be able to customize mine more with specific ID's... So, if I have a Customer that has data: string FirstName, string LastName, string Address. How can I bind my textboxes so that wh...

Django required field in model form

I have a form where a couple of fields are coming out as required when I don't want them too. Here is the form from models.py class CircuitForm(ModelForm): class Meta: model = Circuit exclude = ('lastPaged',) def __init__(self, *args, **kwargs): super(CircuitForm, self).__init__(*args, **kwargs) self.fields['...

Rails: call method within model

Hello all. Can't figure this one out. In rails model, I want to call a method within the same model to manipulate data returned by a find method. This 'filter' method will be called from many custom find method within this model, so I want it to be separate. (and I cannot filter from the SQL it is too complicated) Here is an example: ...

model for resource allocation

I'm working on a time management project and looking for some practical object / persistence models. Fowler has some great ideas on resource allocation in his Analysis Patterns book, but many are overkill for what I need right now, and by design, highly conceptual (as opposed to implementable) The focal conceptual object I'm thinking of...

How can default values in Sequel Models be set?

Given the code below, how can default values be defined for the Model. (let's say the default for :name should be 'Thing'). require 'pp' require 'sequel' DB = Sequel.sqlite DB.create_table :items do primary_key :id String :name end items = DB[ :items ] class Item < Sequel::Model end Item.create :name => 'foobar' Item.create ...

Example models with texture coordinates?

I'm writing a small OpenGL demo and I would really like to show some example models with textures. The trouble is I have a really tough time finding such models. There are tons of repositories of 3D models in various formats but it seems that only a small fraction of them have texture coordinates. I'm looking for find some well known st...

Django - send email on model change.

I want to send an email when a specific field is changed in a model. Is it possible? Here is what I am looking for. I have a profile model that includes a BooleanField that when the administrator selects to be true I want to send user an email. I know I could put it in a "def save(self):" but, that fires off an email anytime the mod...

Django - finding the extreme member of each group

I've been playing around with the new aggregation functionality in the Django ORM, and there's a class of problem I think should be possible, but I can't seem to get it to work. The type of query I'm trying to generate is described here. So, let's say I have the following models - class ContactGroup(models.Model): .... whatever .....

Sort ruby array by updated_at

Hello, all I want to do, is to fetch the lastest item from my models and have them in an array sorted (freshest items first) by the attribute "updated_at". Somewhere is an error, but I can't find it: @results = Array.new Note.find(:all, :limit => 3, :order => "created_at DESC").each do |item| @results << item end Pictur...

How not to repeat this code in my models

Hello everyone. I have this piece of code in a model that sets a start date and end date according to the time of the day that the method is run. Let's jump right into the code example: #MODEL now = Time.now if now.hour >= 17 && now.hour <= 23 #night n = now+1.day startd = Time.local(now.year, now.month, now.day, 17, 00, 0...

What exactly is the model in MVC

I'm slightly confused about what exactly the Model is limited to. I understand that it works with data from a database and such. Can it be used for anything else though? Take for example an authentication system that sends out an activation email to a user when they register. Where would be the most suitable place to put the code for the...

having trouble with cakePHP Bake and one of the database tables

Hi, I am using Bake to create models for my database tables. I have run into a little problem. I have 25 tables .... I strated baking the models until for one of the database tables the bake started giving a name of it own to the model,file and class. For example ,the table in database is named : 'risk_manager' (It has association ...

Zend Framework Model

Hi... is it posible to have a true Model Layer in PHP like in Ruby on Rails? With Zend Framework you can create a Model but this is a class. As I know you have to write all the logic by myself. Solutions? ...

ASP.NET MVC - EntityFramework and Binding to a List

I am currently using the EntityFramework to bind my ASP.NET MVC project to a MySQL database and one of my entities, Product, has an Images property containing a collection of ProductImages. I have built a form to allow the user to modify a given Product and this form includes fields for editing all of the images associated to that Produc...

Too complex models in processing of data

For those that process data, there is a saying: "If you torture data sufficiently, it will confess to almost anything". This is mathematically supported by the Boferroni's theorem, which states that "as one performs an increasing number of statistical tests, the likelihood of getting an erroneous significant finding (Type I error) also i...

Google app engine ReferenceProperty relationships

Hi guys, I'm trying to get my models related using ReferenceProperty, but not have a huge amount of luck. I have 3 levels: Group, Topic, then Pros, and Cons. As in a Group houses many topics, and within each topic could be many Pros and Cons. I am able to store new Groups nice and fine, but I don't have any idea how to store topics und...

Dynamically call a static variable (array)

Hello everyone. Here's my question for today. I'm building (for fun) a simple templating engine. The basic idea is that I have a tag like this {blog:content} and I break it in a method and a action. The problem is when I want to call a static variable dynamically, I get the following error . Parse error: parse error, expecting `','' or ...

Filter and sort music info on Google App Engine

I've enjoyed building out a couple simple applications on the GAE, but now I'm stumped about how to architect a music collection organizer on the app engine. In brief, I can't figure out how to filter on multiple properties while sorting on another. Let's assume the core model is an Album that contains several properties, including: ...