|
I'm rather proud to have produced this Linq assertion on my own:
bool assert1 = (from e in A select B.Contains<T>(e, new TComparer())) .All(x => x == true); bool assert2 = (from e in B select A.Contains<T>(e, new TComparer())) .All(x =&...
Started by Martin on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
OrderSequence(A).SequenceEqual(OrderSequence....
Both sequences should contain a same number of elements anyway .
How about:
Assert.IsTrue(A.SequenceEqual(B, new SomeEqualityComparer()));
following a clarification in a comment I'm adding a sorting of the sequences .
|
|
I have a SELECT statement that works, and runs fast enough on my tables (<0.01sec on 50k+ products, 3k+ categories). But in my mind it's not very elegant and would like to hear any suggestions on making it better.
There are 3 tables of interest:
products...
Started by rwired on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
I believe your query is quite good, but you could compare it with joins:
SELECT DISTINCT pt1.productID FROM products_tree pt1 LEFT JOIN products_tree pt2 ON pt2.productID = pt1.productID AND pt2.categoryID pt1.categoryID WHERE pt1.categoryID IN (1040,... .
|
|
I currently have nodes setup on my site, and each node belongs to a particular menu (not primary or secondary prebuilt menues).
How can i find out which menu a node belongs to?
Started by Shadi Almosri on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Node info is stored in the SQL....
I think you can't do that directly, unless there's some smart module out there that would do all the nasty SQL queries necessary to check this .
I'm a noob, so don't bash me if what I'm going to write is worthless babbling .
|
Ask your Facebook Friends
|
How can I validate Rails model string attribute that it belongs to specific language alphabet characters?
Thanks.
Started by Bogdan Gusiev on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Class Person < ActiveRecord::Base....
The documentation says:
Validates whether the value of the specified attribute is of the correct form by matching it against the regular expression provided .
Validates_format_of seems to be the right thing for you.
|
|
I'm teaching myself Rails, and as a test project I'm mocking up a simple question/answer app similar to stackoverflow.
In my simplified version I have: questions answers users (the authors of questions and answers) I get that answers belong to questions...
Started by normalocity on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
You don't need HABTM in any of ....
Is HABTM the answer between the three classes?
No.
Figure out your has_many relationships and just put belongs_to on the other side and don't worry about the semantics of it.
Belongs_to is a strange name.
|
|
Hi i'm using a has_and_belongs_to_many in a model. I want set the valitor of presence for kinds. and set the max number of kinds per core to 3
class Core < ActiveRecord::Base has_and_belongs_to_many :kinds, :foreign_key => 'core_id', :association...
Started by Luca Romagnoli on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
You could try something like this (tested on Rails 2.3.4):
class Core < ActiveRecord::Base has_and_belongs_to_many :kinds, :foreign_key => 'core_id', :association_foreign_key => 'kind_id' validate :maximum_three_kinds validate :minimum....
|
|
I have following:
User model with columns:
id user_id password created_at updated_at
Store model with columns:
id store_id store_name create_ad updated_at
Basically a user can belong to multiple stores. So I would want to get a query like "get all the...
Started by mustaine on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
How many users belong to a single store.
So you've said that a user belongs to many stores.
|
|
I have two models: releases have many elements, and elements belong to releases.
The action I wish to define imports all elements (making copies of them all) from one release into another release.
How do I determine if this action belongs as a member ...
Started by Angela on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
The best I can verbalize is that since it's always operating on all the elements of a release, rather than ever operating on individual or ad-hoc subsets of elements... .
Now, if I can figure out why I would do that.. .
I would put it on the releases controller.
|
|
I have a MVC application that receives an input from a form.
This is a login form so the only validation that is necessary is to check whether the input is non-empty.
Right now before I pass it to the model I validate it in the controller.
Is this a best...
Started by the_drow on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Business Logic -> Controller Data.
Its business logic, so no, it doesn't belong in the model.
|
|
Suppose i want to check 1.1 belongs to range 0 to 0.5 how can i do it?
with range i can do :
for i in range(0,0.5): if i == 1.1: print 'yes' if i != 1.1: print 'no'
Is ther any other way to do this ????
Answer Snippets (Read the full thread at stackoverflow):
If you want to know if x is inside this range try some form of this:
print 0.0 <= x <=... .
Range() expects integer arguments.
Print 'yes' if 0 < x < 0.5 else 'no'
range() is for generating arrays of consecutive integers
No, you can't do that .
|