I have a Users table and a profile table. The reason they are separate is because information about the user can be put in before they are registered for the site. The problem I'm running into is that when I set the relationship in Sql Server it wants to create a one to many relationship. I don't see any way to change this.
...
Possible Duplicate:
Why doesnt VS 2008 display extension methods in Intellisense for String class
Hi all.
Yesterday I noticed that Enumerable LINQ exstensions are hidden on strings (I mean hidden from the intellisense).
We all know string is an IEnumerable<char>, so automatically it should get Enumerable extensions, and actu...
Hi.. my linq knowledge is ok. i need only a loop or any other method to accomplish ado.net method :(LOOK PLEASE BOLD CODES)
public bool AccessProcess(string sp, ListDictionary ld, CommandType cmdType)
{
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["conn"].ToString());
SqlCommand cmd = new SqlCommand(s...
How can I use dynamic LINQ in Visual Studio 2008?
I'm trying to use
using System.linq.Dynamic
but there is no intellisense. How can I use it?
...
Hi.
I got a problem with Entity Framework 4.0
I have a hierarchical table Category: Id, Name, ParentCategory_Id, timestamp
The "timestamp" field is marked as "Concurrency Mode" = "Fixed"
And I'm using Self-Tracking Entity "Category" to manage Category entity in my MVC application.
The situation:
I create STE "NewCategory",
set ...
Does there exist a LINQ method to group a given collection into subgroups with specified number of elements I mean, something like Scala's grouped method.
e.g. in Scala, List(89, 67, 34, 11, 34).grouped(2) gives List(List(89, 67), List(34, 11), List(34)).
In case such a method doesn't exist, what would be the LINQ way to do it?
...
if i want to filter a list of object against a specific id, i can do this:
list.Where(r => r.Id == idToCompare);
what if, instead of a single idToCompare, i have a list of Ids to compare against.
what is the syntax for comparing against a predefined list. something like
int[] listofIds = GetListofIds();
list.Where(r => r.Id "in...
Hi
I have this sql that i want to have written in linq extension method returning an entity from my edm:
SELECT p.[Id],p.[Firstname],p.[Lastname],prt.[AddressId],prt.[Street],prt.[City]
FROM [Person] p
CROSS APPLY (
SELECT TOP(1) pa.[AddressId],a.[ValidFrom],a.[Street],a.[City]
FROM [Person_Addresses] pa
LEFT OUTER JOIN...
I have a List. I want to print the longest address.
Pseudocode
foreach (var i in listAddr)
{
// access listAddr.Address.Length
// print longest address
// print shortest address
}
...
If I was just wanting the earliest [event] [startTime] I'd write:
events.Min(ev => ev.StartTime);
How can I extend this to say:
"select the [startTime] for the [event] that has the earliest [appointment] [startTime]"
(An [event] has an Appointments collection of [appointment])
...
var sortedAddr = listAddr.OrderBy(x => x.Address.Length);
var longestAddr = sortedAddr.Last();
var shortedAddr = sortedAddr.First();
Now if the longestaddr contains more than one records with the same length, the above piece of code prints only one. However how to print multiple longest address?
...
Hi,
I'm creating a collection of one to one mappings from Foo to Baa.
Baa contains a collection of unique instances of Foo.
Here's some code that does the job:
Dictionary<Foo, Baa> mappings = new Dictionary<Foo, Baa>();
foreach (Baa baa in CollectionOfBaa)
{
foreach (Foo foo in baa.CollectionOfFoo)
{
mappings.Add(foo...
I'm trying to use linq where it makes my code readable - foreach loops generally being easy targets.
Yet there's one that seems simple but yet the linq form escapes me:
const byte EscapeByte = 0x5C;
List<byte> result = new List<byte>();
foreach (var v in values)
{
if (v.Escaped)
{
result.Add(EscapeByte);
}
resu...
I have a linq expression that returns transactions in groups. Each transaction has a numerical value and I now need to know what is the highest value from all the transactions returned. This value is held in a field called TransactionId
Here is the expression I am using to get the grouped list.
var transactions = ctx.MyTran...
Hi
Consider this code:
int size = 100 * 1000 * 1000;
var emu = Enumerable.Range(0, size);
var arr = Enumerable.Range(0, size).ToArray();
when I call emu.ElementAt(size-10) and arr.ElementAt(size-10) and measure the time the arr is much faster (the array is 0.0002s compared to IEnumerable 0.59s).
As I understand it, the extention me...
i have a collection of objects and i am looking to sort by a property that is a DateTime?
list.OrderBy(r => r.Milestone)
where milestone is a:
public DateTime? Milestone { get; set; }
it seems to put all of the items with novalue at the top of the sort. Is there anyway to sort by date but put the empty items at the bottom of t...
Before someone shouts out the answer, please read the question through.
What is the purpose of the method in .NET 4.0's ExpressionVisitor:
public static ReadOnlyCollection<T> Visit<T>(ReadOnlyCollection<T> nodes, Func<T, T> elementVisitor)
My first guess as to the purpose of this method was that it would visit each node in each tree ...
I want to be able to send linq queries over wcf just like in ria services and wcf data services, but I do not want to use either of them.
Are there any codeplex project or similar which could help me with this problem.
Or are there easey to extract that code from ria with reflector?
...
Hi, i have a problem with some data i retrievied from db with linq.
When I try to access data I obtain the following exception:
System.ObjectDisposedException : The istance of ObjectContext was deleted and is not possible to use it again for action that need a connection.
This is the code:
using (ProvaDbEntities DBEntities =
new ProvaDb...
I have a method that gets rows from my database. It looks like this:
public static IEnumerable<Dictionary<string, object>> GetRowsIter()
{
_resultSet.ReadFirst();
do
{
var resultList = new Dictionary<string, object>();
for (int fieldIndex = 0; fieldIndex < _resultSet.FieldCount; fieldIndex++)
{
...