I work w/ Rhino Mocks 3.5 a lot but recently came across something I had never tried before. I want to stub out a service and setup the return value - simple stuff really
The only issue is that now my service isn't returning IList, but instead IQueryable
So when I try to do something like this - it blows up
<TestMethod()> _
Publi...
I am trying to update some object properties by calling UpdateModel(myObject, new[] { "stringprop1", "stringprop2", "intprop"}).
This is failing for an unknown reason. Several string properties are updating successfully. When I try to update an int property it fails. The new int value is being sent from an html select list on the view.
...
Hi all,
I have a table called "Sentence" that has the following fields:
ID <--- OK
NextID <--- FK To ID
Text
So if I had the following records:
*ID* *NextID* *Text*
1 12 The quick
3 40 jumps over
5 null lazy dog.
12 ...
I have a XDocument with XElements such as this:
<PageContent>
<Text>My Text</Text>
<Image>image.jpg</Image>
</PageContent>
I want to find the Text element and update its value. I have some LINQ working but its returning the value rather than allowing me to update the XElement and XDocument in return.
...
I've been having trouble articulating the differences between ILookup<TKey, TVal> and IGrouping<TKey, TVal>, and am curious if I understand it correctly now. LINQ compounded the issue by producing sequences of IGrouping items while also giving me a ToLookup extension method. So it felt like they were the same until I looked more closely...
Below query works fine for me until I apply Where condition for Hour with attribute Id = '06/02/2009 12:00CDT'.
I need to get the max temp for today's date only, and I am not able to use the Where condition in the date field. Any ideas on what I am doing wrong?
Dim document = XDocument.Load("c:\meridian.xml")
Dim wind_gusts = From cou...
I don't care about the order of the elements.
http://msdn.microsoft.com/en-us/library/system.linq.enumerable.union.aspx
http://msdn.microsoft.com/en-us/library/bb302894.aspx
...
Whats the general consensus on using LINQ to perform quieries and manipulation inline and how does this differ to embedding SQL statements into your code which is considered a no no.
...
I want to show the attribute of a relation in a DataGridView. I use LINQ to SQL to do the mapping and have the following classes:
class Computer
{
public string Name;
public User User;
}
class User
{
public string Name;
}
I use a DataGridView to show some rows of the Computer entity and also want to have one column to sho...
I want to test whether a certain string is contained in a short list of strings. Currently the code is like this:
if (new List<string> { "A", "B", "C" }.Contains (str)) {
However, this seems bloated. For instance, iirc, in Java I could simply write {"A", "B", "C"}.Contains(str) which would be much preferable to the above.
I'm sure th...
I have the following two tables:
Customer
{
int Id
int Name
}
Bills
{
int Id
int CustomerId
decimal Amount
bool IsDue
}
Now I am trying to get a list where I have:
A entry for every customer with the count of associated bills.
A entry for every customer with the count of associated bills where IsDue is true.
I tried doing the fir...
is there any tool or utility(mapper assembly) to construct business objects from entities(which are obtained from DB using linq -> sql , entity framework or whatever..)
in the absence of one , can anyone suggest the best way that can be accomplished rather can copy pasting the properties(what i'm doing right now) from the entity classes...
I have a query with single result. The result is an anonymouse type. How can I use access the type so I don't have to use query.Single() every time?
This is my query:
var result = from row in db.Table
select new { CustomName = row.RowName };
This is how I use it right now:
string name = result.Single().CustomName;
Of course my re...
Hi all,
I've got the following situation:
var totalRecords = (from entry in invalidAccEntryRepository
select entry).Where(entry =>
entry.CustomerAccountInfo.CustomerAccountName == CustomerAccountName &&
entry.CustomerAccountInfo.CustomerAc...
How would you approach this problem with an ORM?
This is a hypothetical (simplified) example:
I have a table of cities:
1 - New York
2 - London
3 - San Francisco
4 - New Orleans
I have a table of scores:
(first column Unique Primary Key, second Month Code, third FK to City, fourth Score (int))
1 - 352 - 1 - 9
2 - 352 - 2 - 10
Fo...
I'm trying to rewrite some old SQL into LINQ to SQL. I have a sproc with a GROUP BY WITH ROLLUP but I'm not sure what the LINQ equivalent would be. LINQ has a GroupBy but it doesn't look like it supports ROLLUP.
A simplified example of the results I'm trying to get would be something like this:
City | ServicePlan | NumberOfCusto...
I am using LINQ to SQL with Sql Server Compact Edition 3.5 and VS2008.
I have a very simple table (Tokens) with a uniqueidentifier primary key (TokenID) and two other nullable fields (UsedBy and UsedOn). I am trying to use LINQ to insert new rows into the table but for some reason they are not persisting.
Here is my code:
var ...
Is there any method to select a column of the current row of a BindingSource whose DataSource is an anonymous class?
var userResults = from u in dataContext.Users
join c in dataContext.Computers on u.ID equals c.UserID
where doSearch
&& u.Name.Contains(userNameTextBox.Text)
&& u.UserName.Contains(userUsername...
I think this may be a very simple question, but I am only just starting out with .net and c# at all, and only really just finally getting my head around OO stuff.
I have built the NerdDinner application, and I am building on top of it currently with my own project.
What I need to do, in the context of nerd dinner, is display the detail...
I'm trying to return attributes of columns from my DataContext.
How can I pull out the ColumnAttribute meta data?
public class MyDataContext : DataContext
{
public Table<User> User;
public MyDataContext(string connection) : base(connection) { }
}
[Table(Name = "User")]
public class User
{
[Column(IsPrimaryKey = true)]
...