Is there an equivalent for ActiveRecord#find_by equivalent for C#?
Posted
by Benjamin Manns
on Stack Overflow
See other posts from Stack Overflow
or by Benjamin Manns
Published on 2010-04-04T22:30:46Z
Indexed on
2010/04/04
22:33 UTC
Read the original article
Hit count: 232
I'm originally a C# developer (as a hobby), but as of late I have been digging into Ruby on Rails and I am really enjoying it. Right now I am building an application in C# and I was wondering if there is any collection implementation for C# that could match (or "semi-match") the find_by method of ActiveRecord.
What I am essentially looking for is a list that would hold Rectangles
:
class Rectangle
{
public int Width { get; set; }
public int Height { get; set; }
public String Name { get; set; }
}
Where I could query this list and find all entries with Height = 10
, Width = 20
, or name = "Block"
. This was done with ActiveRecord by doing a call similar to Rectangle.find_by_name('Block')
. The only way I can think of doing this in C# is to create my own list implementation and iterate through each item manually checking each item against the criteria. I fear I would be reinventing the wheel (and one of poorer quality).
Any input or suggestions is much appreciated.
© Stack Overflow or respective owner