I have a sample class like this:
SampleClass
{
string code;
int id;
string name;
}
Valid data for the class would be:
SampleClass{code= "code1", id= 1, name= "name1"}
SampleClass{code= "code1", id= 1, name= "name2"}
SampleClass{code= "code2", id= 2, name= "name1"}
SampleClass{code= "code2", id= 2, name= "name2"}
Sa...
I use the LINQ to SQL Classes to access to my database. Now I want to use the LINQ to SQL Classes for WPF DataBindings and validation. How do I implement these two interfaces to my projects Model? Is it possible implement INotifyProperty automatically?
...
Note:
I know there was disscussion about similar questions before, like in:
link text
but i have to know how to handle this scenario:
Problem:
I wrote program that use LINQ to SQL and it will be send to client. Tables that my program uses may be changed ( let's say only added new columns). Is there any way to not update, recompile a...
UPDATE:
I did not realise that Thomas Levesque had posted a solution and worked on my own below one in the meantime. I’m not using C# / VS2010 for long but I must say that C# is unbelievably productive and I am kicking myself that I stuck with C++ and put off learning C# for so long.
Stack<string> LdifUserStack = new Stack<string>(...
Hi,
I have 2 list:
myObject object1 = new myObject(id = 1, title = "object1"};
myObject object2 = new myObject(id = 2, title = "object2"};
myObject object3 = new myObject(id = 3, title = "object3"};
//List 1
List<myObject> myObjectList = new List<myObject>{object1, object2, object3};
//List 2
List<int> idList = new List<int>{2, 3};
...
I'm getting tossed into an existing codebase, and part of the job is to get the code gradually under test as I make updates. So it's a process of taking something old and ugly and making it nicer.
In this case, there is a code similar to this:
foreach (var thingamajigLocator in thingamajigLocators)
{
Thingamajig thingamajig;
tr...
hi,
I have an existing class Image which is used extensively throughout my application.
I need to return a generic list of images (List) to the frontend but as there is no stored proc in the 3ed party DB I am quering I need to use Linq to Sql.
I have create a dbtm file of the database I am quering in my DAL which looks like:
ImageCat
...
i need a discussion regarding the Performance of LINQ and Lambda Expression.
Which one is better??
...
Given a collection of the following class:
public class Post
{
...
public IList<string> Tags { get; set; }
}
Is there an easy way to get all Posts that contain a tag starting with "foo" using LINQ?
var posts = new List<Post>
{
new Post { Tags = new[] { "fooTag", "tag" }},
new Post { Tags = new[] { "barTag", "anyTag" }...
I want to extend the default LINQ provider for NHibernate 3 with methods of my own. I want to be able to use some methods from my POCOs. I have a component named Range which is used quite often in many of my POCOs. This nhibernate component class has a method Contains(int value) that I want to use in LINQ query expressions
Mapping:
<cl...
I have the following piece of code
public static Func<PurchasingDataContext, int, int, List<Requisition>>
GetRequisitions = CompiledQuery.Compile((PurchasingDataContext context, int userid, int requisitionState)
=> context.Requisitions.Where(r => r.UserId == userid && r.RequisitionId == requisitionState).ToList());
publ...
I have a Typed DataSet DataTable which inherits TypedTableBase<T>, which in turn implements IEnumerable<T>. I can't seem to get this to work.
myDataTable.OrderBy(x => x.ID).ThenBy(y => y.ID2);
Instead I have to assign this statement to an IEnumerable(or List), then refill my DataTable manually with the newly ordered IEnumerable before...
Hello,
In some instances, we may have PK/FK references duplicated, so entity A and entity B are in a PK/FK relationship, but 3 times. So entity A would have 3 FK collections and entity B would have 3 entity references. How does that work with the code-first template? Do you follow the naming convention of Entity Framework model/datab...
I need to be able to add an unkown number of where clauses to a Linq query. Currently I have been trying to combine the queries using Concat(). For example:
var r1 =
from field in db.fields
where ID == 1
select field;
var r2 =
from field in db.fields
where ID == 2
select field
var r3 = r1.Concat(r2);
This is...
I have three tables I'm getting info from: User, Field, FieldUserInput. I already know the userId which is what I use to find out what fields the user has input. Then I want to get the value of those fields that the user has input in FieldUserInput.
I first wrote this query in plain old sql but I want to use LINQ as much as possible sin...
For example consider:
var hset = new HashSet<int>();
// Fill the hset.
var enumerable = hset as IEnumerable<int>;
bool enumerable.Contains(0);
Does LINQ use the fact that the HashSet has an efficient implementation of Contains, or does itsimply operate on the enumerator as one would expect?
The reason I'm asking is that the componen...
Consider following LINQ-to-NHibernate queries:
var q1 = from se in query.ToList<SomeEntity>()
where
prop1 == "abc"
select se;
var q2 = from se in q1
where
m1(se.prop2) == "def"
select se;
q2 will not work with error: "The method m1 is not implemented". But when replace q2 with following query, everything goes ok:
var q...
When I try to update Linqdatsource binded to gridview get following error
"Could not find a row that matches the given keys in the original values stored in ViewState. Ensure that the 'keys' dictionary contains unique key values that correspond to a row returned from the previous Select operation."
Note :- I have specified DataKeyNames ...
I have a class with a DateTimeOffset property:
public class Sample
{
public DateTimeOffset expires { get; set; }
}
and eventually a collection of them:
IEnumerable<Sample> collection;
2 questions:
What is the best way to create a method that returns all the Sample items from the collection where expires is greater than n...
Hi all,
We're trying to decide if it's worth using entity framework 4 on a project. To that end, I think a good place to start would be by comparing it to nhibernate, which is mature and proven by years of use to have all the features people need for enterprisey apps, and find out what features nHibernate has that EF4 is missing out on....