I've been reading Chapter 11 (Testable Design Patterns) in the Professional ASP.NET MVC 1.0 book. In the examples in this chapter, data access is split into a number of repositories: IOrderRepository, IProductRepository, etc. That all makes sense: a single repository for a single class of data.
However, this breaks down somewhat for me...
I have one table having ID and other attributes.
How can I get list of int of IDs by LINQ query on that table?
...
It's a novice question so be kind to me :)
How can I consume a php API in ASP.NET? This API returns an XML document. It is also capable of returning JSON.
The output is shown below
XML
<?xml version="1.0" encoding="UTF-8"?>
<Address>
<Country>US</Country>
<City>Seattle</City>
<Result>Done</Result>
</Addre...
Has anyone compared the speed of performance between LINQ to SQL against the Entity Framework?
I have heard that LINQ to SQL is 4 times faster than the Entity Framework, but I've never seen any bench marks or sample application proving this.
...
How do you get a list of all the tables and use that list to enumerate the columns?
I've found posts that describe one or the other, but not both.
My net-result is I want to generate a static class which contains names of all the columns in each tables so I could, for example, do:
comboBoxFoo.DisplayMember = SomeNamespace.SomeTable.Som...
I am having trouble efficiently selecting the information I need to display. Hopefully someone else has a better idea of how to solve this.
Given the following data structures,
public class Department
{
public int ID { get; set; }
public string Name { get; set; }
public IList<Product> Products{ get; set; }
}
public class Prod...
lets say i have a table with a DateTime field and a int field and perform a query like this:
var query = context.tblSomeTable.Where(s=>s.Name == "Hello World").OrderBy(s=>s.SignUpDate);
if I then perform two subqueries with the result, are they still ordered by the date?:
var sub1 = query.Where(s=>s.Id = 5);
var sub2 = query.Where(s=...
Hello all,
the dbml file generated by Visual Studio (sqlmetal) comes with entities mapped to database tables. In your opinion, these clases are suitable to be used as domain model classes? Or should we avoid them and isolate them into the data access layer only?
Thanks
...
Hi ,
i'm working on Linq To Sql,WPF and i have a database now i need to save some picture in the database but i don't know which is the correct datatype to save the pictures Database(this database would be connect from 10 users in the same time).
Can you point me in the right way to overcome this step?
If i didn't wrong it is not a good...
XDocument.Load throws exception, when using XML file name of xml with version 1.1 instead of 1.0
Any clean solutions to resolve the error (No regex) and load the document?
...
Is there an easy way to convert all the columns of the current row of a SqlDataReader to a dictionary?
using (SqlDataReader opReader = command.ExecuteReader())
{
// Convert the current row to a dictionary
}
Thanks
...
I've been playing around with the DLR a bit and am a bit stuck on calling methods. For example, suppose I want to make an expression to push something onto a stack:
class StackInfo{
protected Stack<SomeClass> _stack;
public Expression Push(SomeClass item)
{
MethodInfo mi = _stack.GetType().GetMethod("Push");
...
I have a Person object with a Nullable DateOfBirth property. Is there a way to use LINQ to query a list of Person objects for the one with the earliest/smallest DateOfBirth value.
Here's what I started with:
var firstBornDate = People.Min(p => p.DateOfBirth.GetValueOrDefault(DateTime.MaxValue));
Null DateOfBirth values are set to Da...
Hi guys, How you doing today? Wish you all good.
By the way, here is my problem. I would like to display the total of sum duration in gridview by using LINQ to SQL. I have two tables, Users and Log_Times
Users
UserID-----Name
1------------Bob
2------------Mary
3------------Jane
Log_Times
ID---------------UserID--------------------Time...
How is the method SingleOrDefault() evaluated in LINQ? Does it use a Binary Search behind the scenes?
...
I'm trying to create a LinqDataSource to bind to a DropDownList in an ASP.NET form. I only want to show the elements according to a date (which is one of the fields in the database).
Basically, the elements I want to show are the ones that will happen in the futures (i.e. after DateTime.Now).
I was trying the following markup :
<asp:...
I am trying to do something similar to this sample code from Phil Haack to VB, and LINQ Orderby is giving me problems - and I can't figure out how to do this. Entire method posted for completenes.
This is the C# version:
public ActionResult DynamicGridData(string sidx, string sord, int page, int rows)
{
var context = ne...
I have the following bit of code:
Expression<Func<Subscription, Service>> service2= subscription => (from relationship in subscription.ChildRelationships
select relationship.SecondService).FirstOrDefault();
It creates an expression that I can use later as part of a query with the entity framework. The actual code I'm using has a w...
I'm working with the Entity Framework and I'm having a problem:
When I try to insert some data in a table it tells me that it's violating integrity of reference but the other table is normally populated and has the value i'm trying to insert.
Pedido pedido = new Pedido();
pedido.Data = DateTime.Now;
db.AddToPedido(pedido);
db.SaveCha...
For my function
public static IEnumerable<CallbackListRecord> LoadOpenListToProcess(CallbackSearchParams usp){}
This line errors when the sequence contains no elements (as it should)
CallbackListRecord nextRecord = CallbackSearch.LoadOpenListToProcess(p).First();
I have changed it to the following
CallbackListRecor...