Hi,
Using LINQ, what is an efficent way to get each string from a tab-delimited .txt file (and then get each word, usually what string.Split(...) does)?
var v = from line in File.ReadAllLines()
select n
Is part of this solution I believe. I don't mind if this uses yield return.
EDIT: I've also seen threads on here detailing exact...
I'd like a cheetsheet that contains the most common keywords and syntax, all contained on a single pdf page.
...
I have the following method to apply a sort to a list of objects (simplified it for the example):
private IEnumerable<Something> SetupOrderSort(IEnumerable<Something> input,
SORT_TYPE sort)
{
IOrderedEnumerable<Something> output = input.OrderBy(s => s.FieldA).
ThenBy(s => s.FieldB);
switch (sort)
{
case S...
I have this compiled query:
private static Func<DBContext, Foo> FooQuery = CompiledQuery.Compile<DBContext, Foo>(
_db => _db.FooTable.SingleOrDefault(f => f.DeletionDate == null || f.DeletionDate > DateTime.UtcNow)
);
When I run it once, it returns the expected Foo object.
But then, even after that object's DeletionDate is set in...
XML sample (original link):
<records>
<record index="1">
<property name="Username">Sven</property>
<property name="Domain">infinity2</property>
<property name="LastLogon">12/15/2009</property>
</record>
<record index="2">
<property name="Username">Josephine</property>
<property name="Domain">infinity3</property...
I'm using two LINQ queries to access my database using Entity Framework:
The first stores a token in the database and gives it a 60 second timeout:
string tokenHash = GetTokenHash();
Token token = new Token()
{
Client = client,
Expiry = DateTime.Now.AddSeconds(60),
UserId = userId,
TokenHash = tokenHash,
};
context.AddT...
Nowadays I see in some developers, use function named GetAll or Getlist in each class. These functions return a list or entity of it's class.
After that, they use these function like this:
dim k = from t in customer.GetAll, p in Product.GetAll where ....
I think there will be a performance problem about this using. Because firstly a...
Hello,
I have on my EF Schema a relationship * - * (designed by a middle table with 2 keys).
When I want filter on each (ie : I want all market segment filtered by one function), I execute this query :
var requete = from mkt in ent.MARKETSEGMENT_MKT
where mkt.FUNCTION2_FUN.Where(fu => fu.FUN_ID == FunId).FirstOrDefault().FUN_ID == Fu...
Hi.
I'm currenty trying some new things with OpenXml but I recently came across some trouble. As the title says I'm trying to insert data dynamically into a table using Xml. To indentify the table in my Worddoc I've put a Rich Text Content Control arround it.
Everything worked & looked fine until I tried to search my document for the t...
Is there a better way to cast this list of guid strings to guids using linq:
public static IList<Guid> ToGuidList(this IList<string> guids)
{
IList<Guid> guidList = new List<Guid>();
foreach(var item in guids)
{
guidList.Add(new Guid(item));
}
return guidList;
}
I looked at: ...
Im trying to write a List of 'Documents' from an XML string, but i was wondering what is the best way to get the value of a node of certain attribute.
More specifically in the sample I would like to set the value of aDocument.Source to the text "The Source" of the "field" node that has the "Source" value for the "name" attribute.
Sampl...
I use LinqDataSource in my web pages and I want to handle Business rules in Changed event of properties and also OnValidate method of an entity.
I can delete other entities in partial delete also, I can upload other entities in partial Insert and Update methos but I can't Insert entites in partial update or delete methods.
Example : I ha...
I am researching how LINQ expressions get compiled into code...more specifically the function chaining that gets generated. (The background reason for this is I wanted to more thoroughly understand the objects that get created during joins. I need to code for a COALESCE in the SELECT for two properties from the different tables.)
I tend...
Hello, I'm new to EF and I've been using the asp.net mvc databind method to update my models "tryupdatemodel", now I have to update a entity from a service layer, since TryUpdateModel is a asp.net mvc method I can't use it in the services layer.
What I need to do to update the data of an entity without using this method?
I'm using repo...
I have an object with two different integer properties in it, and I'm trying to get a a new object in Linq to Entities, combining two integer properties from the same object as concatenated strings, as follows
List<DateRange> collection = (from d in context.dates
select new DateRange
{
DateString = from s in context.Seasons
wher...
I have the following table structure, which is imported into an Entity Framework project:
(NOTE: I mislabled T1Name as T2Name in Table1)
I have labeled the Entity Objects. The many-to-many joint table Table5, is represented as an EntityCollection<Entity4> in Entity3, and as an EntityCollection<Entity3> in Entity4 (EntityCollection<T>...
Hello,
I have a C# application that loads a List of CLR objects called "Tasks". Each Task has the following properties:
public int ID { get; set; }
public int TypeID { get; set; }
public string TypeName { get; set; }
public string Name { get; set; }
I am trying to find the unique types of tasks in this list. I thought I would try to ...
I have a table with a column of type varchar where the majority of rows have numerical looking values, that is, each string contains nothing but the digits 0 through 9.
+------+
| n |
+------+
| 123 |
| 234 |
| BLAH | -- This row is an exception to the rule.
| 456 |
| 789 |
+------+
In MySQL, this works: SELECT * FROM t WHERE n...
from a list, which got 3 attributes
I want to return a new list of that class where attribut1 recurrence in the list equals X
for an example this;
1,a,b
1,c,d
1,e,f
2,a,b
2,c,d
3,a,b
3,c,d
3,e,f
4,a,b
5,a,b
5,c,d
5,e,f
6,a,b
6,e,f
where X = 1 would return that list
4,a,b
where X = 2 would return tha...
Today in my office there was a question of how to say PLINQ as in "P LINQ" or "plinq" all one word. Does anyone have a definitive answer?
...