Hi i am using linq to get the data from list but as i get the in linq i use foreach loop to add it in generic list but i got error " Value cannot be null. Parameter name: source"
i am using c# With .net
my code
var nCounts = from sale in sal
select new
{
...
Hey All,
I have a string full of a few hundred words.
How would I get each "word" (this can also be a single letter number or punctuation), and as each "word" is found, it is removed from the string.
Is this possible?
Example:
String:
"this is a string full of words and letters and also some punctuation! and num6er5."
As far as th...
I have an interface defined as below:
public interface TestInterface{
int id { get; set; }
}
And two Linq-to-SQL classes implementing that interface:
public class tblTestA : TestInterface{
public int id { get; set; }
}
public class tblTestB : TestInterface{
public int id { get; set; }
}
I have IEnumerable lists a and b...
I want to write a function that reads a file and counts the number of times each word occurs. Assuming the file-reading is handled and produces a list of strings representing each line in the file, I need a function to count the occurrence of each word. Firstly, is using a Dictionary<string,int> the best approach? The key is the word, an...
I have a Masterpage that has Treeview. You can select some nodes there.
Based on the selection you get some items in the Default.aspx's Placeholder, you get a image and a linkbutton placed in a Panel. Like this :
This code is in the Default.aspx that has the Masterpage.
TreeView nav_tree = ((TreeView)Master.FindControl("treev...
I'm interested in the history of Linq. How it was first conceived, how it grew from an idea, how it was developed to the technology it is today. Is anyone aware of a document or video that would give such a history? I know there is a Channel 9 video with Anders Hejlsberg from 2005, but this isn't what I'm looking for.
Thanks.
...
I'd like to have the following API for my MyTypeRepository:
var myChosenInstance = _myRepository.FindOne(x => x.MyProperty == "MyValue");
..and for the lambda to use used to construct a linq query within the repository, which is then used by Linq to NHibernate.
Is this possible? What would my repository FindOne method look like?
...
I'd like to expose a Repository as an 'IQueryable' type.
The repository uses Linq to NHibernate to communicate with the database.
Can anyone point me at an example implementation?
For example, what would the corresponding 'GetEnumerator()' implementation on my repository look like?
Edit:
Would something like this be appropriate?
pu...
i try to add data with ExecuteCommand. everything is ok if list<string> data. i converted string type list into arraylist to add sql. But <MyClass> there are rows and column. look below picture.
public class MyTally : ISave
{
public List<ENG_MPD> engMpdIntersectList { get; set; }
private ArrayList engMyTallyList;
...
I seem to be having issues with getting my jqgrids working well with linq to sql in my asp.net mvc project.
The issue I am having is correctly using the sidx and sord parameters. Most resources I find say to do something like
var questions = context.Questions
.OrderBy(sidx + " " + sord)
.Skip(pageIndex * pageSize)
.Take(pageSi...
i dislike below methods. Because more fields (suchas 150 fields) it is not good method. There is any SetValue method to add datato sql linqtosql for submitchanges?
MyClass c = new MyClass ();
c.FirstField = "bvnvb";
c.......
c...
c...
// Too many rows there is...
...
I have a List<SomeType> where
SomeType.Value = "TASK?" where '?' can be from 1 to N.
SomeType.Value can also have values like TASKCNT, TASKOLD etc..
The question is how do I Select all "TASK?" ignoring other values like TASKCNT, TASKOLD
Thanks in advance
...
This is kind of hypothetical as I'm thinking about how to design this. Consider this query with some literal integer values in the join criteria:
Select *
From LeftPeople l
Inner Join RightPeople r On r.RecordId = l.RecordId and r.ResultId = 3 and l.ResultId = 7
Would this be the correct equivilant in LINQ? It seems kind of a cludg...
Say I have the code below that uses LINQ to SQL:
MyDataContext dc = new MyDataContext;
var items = from f in dc.TableName
where f.ChildId == 4
select f;
If the table TableName has a column called Completed is it possible for me to set the Completed column to true for everything selected above?
...
Currently if we get direction of ordering as an external dependency we have to use if to apply this direction:
public static IEnumerable<FileInfo> getlist(string directory, string searchPattern, string order)
{
var files = new DirectoryInfo(directory).EnumerateFiles(searchPattern);
if (order == "A")
return files.OrderBy...
How can i right this in method Expression!
var query =
from l in list where l.Key == "M"
select new { Value = l, Length = l.Length };
...
How to: you don't want to manually write code to write to ColumnA, ColumnB, etc, then you could use reflection to write to the appropriate properties on the entity?
you can create a new instance of this class and its property values. These property values are mapped to columns in the SQL database table. You then pass this object to the D...
What would be considered best practice for updates when using LINQ:
To have an instantiated db/facade
object, and submit all changes to a
record in one go?
To have a static db/facade object,
and submit changes cell by cell?
Right now I'm in a project where each cell for a record has its own static update method
public static void Ce...
I have a collection of string names, few names starts with X100,x200,x121 which has numeric values.
I'm using LinQ to loop thro and also using a where clause to filter those names that has integer values like x"100." Which is the best way to do accompolish this?.
is it possible to use Func or Action on the items for checking each string ...
Hi there,
here is my Linq code to generate a list of random numbers which contains 10 numbers ranging from 0 to 20
Random rand = new Random();
var randomSeq = Enumerable.Repeat(0, 10).Select(i => rand.Next(0,20));
Result:
6
19
18
7
18
12
12
9
2
18
as you can see i have three 18s and two 12s..
I have tried to use Distinct(...