I'm a newbie in the NHibernate world.
Why this code works removing the territory from the collection:
Country country;
using (IUnitOfWork unit = UnitOfWork.Start())
{
country = new Country();
country.Name = "My country";
Territory territory = new Territory();
country.Territories.Add(territory);
country.Territories...
I have an array that I want to permutate randomly. In Java, there is a method Collections.shuffle() that can shuffle the elements of a List randomly. It can be used on an array too:
String[] array = new String[]{"a", "b", "c"};
// Shuffle the array; works because the list returned by Arrays.asList() is backed by the array
Collections.s...
I have a List of Map[String, Double], and I'd like to merge their contents into a single Map[String, Double]. How should I do this in an idiomatic way? I imagine that I should be able to do this with a fold. Something like:
val newMap = Map[String, Double]() /: listOfMaps { (accumulator, m) => ... }
Furthermore, I'd like to handle ...
Is there a collection class that has the LinkedHashMap quality of a predictable iteration order, but at the same time being indexable? LinkedHashMap implements a get() method, which returns the value object, but an indexof() method is not available. I'd like both.
Thanks.
...
Hi,
In my BL (will be a public API), I am using ICollection as the return types in my Find methods, like:
public static ICollection<Customer> FindCustomers()
{
Collection<Customer> customers = DAL.GetCustomers();
return customers;
}
Note the use of ICollection instead of Collection<>.
Now in my GUI, I need to cast the results...
I've to deal with an immutable object in scala 2.7.5, and one of its member is an immutable Sortedset.
I've no problem with addition, to synthetise, it gives:
class MyClass[A](s:SortedSet[A]) {
...
def + (elem:A):MyClass[A] {
new MyClass(s + elem)
}
}
And it works, since + operator is overload in trait sortedSet to return a...
In a Flex webapp, is there an easy way to go about applying a sort to the children of an XML element, based on the children's attributes? Example follows below:
XMLListCollection:
<a anotherProp="ABCDE">
<e prop="AB">1</element>
<e prop="BC">2</element>
</a>
<a anotherProp="FGEH">
<e prop="HF">3</element>
...
Hi folks,
I am currently using a Linq template with SubSonic3 to create my models. I have a simple Member class, which has a collection of Notes. A Note class has a PublishedDate and Title properties.
I have a UserControl which has a collection of Members for its DataContext. There are two ListBoxes and a bunch of TextBoxes and other c...
Hello community,
I want to have a generic thread safe collection and I saw that the Arraylist can easily be used thread safe by its static Synchronized method but what bugs me is that this ArrayList is not generic so when I want to use my objects I always have to cast them. Is there an easier way to do this? Also other list types would ...
There is any method to truncate a list in java, for example, to the first 100 elements, discarding the others?
(I mean, without iterating and/or copying/deleting elements one by one)
...
Hi, i am trying to obtain an item from a collection that occurs most frequently. if i were in SQL i would do something like this..
select top(1) extension from database.table
group by extension
order by count(extension) desc
but im trying to do this using linq.
Can someone assist with the translation?
so far i have this but its not ...
How do I, without using any loop, modify the values in a collection to get a new collection with the modified values?
For example, I'm having a Collection<String> and want to surround all Strings by parentheses.
With a loop I would do this:
Iterable<String> collection = getCollection();
ArrayList<String> newCollection = new ArrayList<...
Hey,
So here's the problem. Imagine 2 models: Photographer and Photo. Strict rule is that there can be only 1 photographer for image, so in Photo there's a ForeignKey link to Photographer.
class Photographer(models.Model):
name = models.CharField(max_length = 40)
class Photo(models.Model):
name = models.CharField(max_length =...
Is there a .NET equivalent of Java's List.subList() that works on IList<T>?
...
When should I use an ArrayList in Java, and when should I use an array?
...
The only one I can find is the BoundedFIFOBuffer, which is deprecated. Any others?
...
I am interested, if it is possible to have collection with same elements in .Net configuration.
Like this, for example:
<RetrySettings>
<RetryTurn PeriodBeforeRetry="0:05:00"/>
<RetryTurn PeriodBeforeRetry="0:10:00"/>
<RetryTurn PeriodBeforeRetry="0:30:00"/>
<RetryTurn PeriodBeforeRetry="1:00:00"/>
<RetryTurn ...
Hi everyone.
I am not familiar with js and jQuery, but need to create function to add/remove blog post to "My favorites" page and update counter of saved posts. Is any ready solution - plugin or snippet - to it?
There is my html snippet.
<h1><a href="http://www.example.com/add-post-to-my-favorites-page.htm" id="post_0064"><span class...
My bidirectional collection mapping seems to only work in one direction. One job will have some number of costs. Each cost is associated with one job. The problem is, when I load a job, the costs collection is empty. However, when I load a cost and navigate from it to the job and then check the costs collection, it is properly filled. Ca...
The Setup
I have a WCF service that exposes a base type (e.g. Animal) as well as a few derived types (e.g. Lion, Tiger, and Bear). Another type (e.g. Zoo) includes a property that is a collection of the base type. The base type is concrete, not abstract, so it is perfectly acceptable for the collection to contain instances of the base t...