Click here to Skip to main content
14,485,669 members
   

C#

 
QuestionDialogfenster auf- und zuklappen (Open and close dialog window) Pin
CopWorker23-Jan-20 0:36
MemberCopWorker23-Jan-20 0:36 
AnswerRe: Dialogfenster auf- und zuklappen (Open and close dialog window) Pin
Gerry Schmitz23-Jan-20 4:11
mveGerry Schmitz23-Jan-20 4:11 
QuestionGet Data From Deserialized List By Type Pin
Kevin Marois22-Jan-20 8:45
professionalKevin Marois22-Jan-20 8:45 
AnswerRe: Get Data From Deserialized List By Type Pin
Richard Deeming22-Jan-20 9:01
mveRichard Deeming22-Jan-20 9:01 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois22-Jan-20 9:15
professionalKevin Marois22-Jan-20 9:15 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois22-Jan-20 11:12
professionalKevin Marois22-Jan-20 11:12 
GeneralRe: Get Data From Deserialized List By Type Pin
Richard Deeming23-Jan-20 0:48
mveRichard Deeming23-Jan-20 0:48 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois23-Jan-20 7:35
professionalKevin Marois23-Jan-20 7:35 
OK, so I implemented your first code snippet. It works.

What I left out before was that this all goes in a repository. I currently have a MongoDB repo, and now I'm implementing the IRepository interface to deal with the serialized version of the data. Now I have a new issue:

This Works
public T Get(Guid id)
{
    return Data.Where(x => x.Id == id).FirstOrDefault();
}
This Doesn't Compile
public T Get(Expression<Func<T, bool>> predicate)
{
    return Data.Where(predicate).FirstOrDefault();
}
The error is "'List<t>' does not contain a definition for 'Where' and the best extension method overload 'Queryable.Where<t>(IQueryable<t>, Expression<func<t, bool="">>)' requires a receiver of type 'IQueryable<t>'"

The problem is that List<t> isn't an IQueryable. If I change method signaature to accept a delegate instead of an expression, it works.
public T Get(Func<T, bool> predicate)
{
    return Data.Where(predicate).FirstOrDefault();
}
I could add this method to the interface, but I'd rather not change existing code if I don't have to. And it causes abiguity beetween the two Get methods.

I'd like to hear your thoughts on this. And thanks for your help so far.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

GeneralRe: Get Data From Deserialized List By Type Pin
Richard Deeming23-Jan-20 9:34
mveRichard Deeming23-Jan-20 9:34 
GeneralRe: Get Data From Deserialized List By Type Pin
Kevin Marois23-Jan-20 7:51
professionalKevin Marois23-Jan-20 7:51 
AnswerRe: Get Data From Deserialized List By Type Pin
BillWoodruff22-Jan-20 21:44
mveBillWoodruff22-Jan-20 21:44 
AnswerRe: Get Data From Deserialized List By Type Pin
Gerry Schmitz23-Jan-20 4:14
mveGerry Schmitz23-Jan-20 4:14 
QuestionException thrown: 'System.IO.FileNotFoundException' sqlite Pin
Member 1472399222-Jan-20 8:41
MemberMember 1472399222-Jan-20 8:41 
AnswerRe: Exception thrown: 'System.IO.FileNotFoundException' sqlite Pin
Richard Deeming22-Jan-20 8:54
mveRichard Deeming22-Jan-20 8:54 
Questionhow flip the canvas vertically ? Pin
Le@rner22-Jan-20 1:56
MemberLe@rner22-Jan-20 1:56 
AnswerRe: how flip the canvas vertically ? Pin
OriginalGriff22-Jan-20 2:29
mveOriginalGriff22-Jan-20 2:29 
GeneralRe: how flip the canvas vertically ? Pin
Le@rner22-Jan-20 19:19
MemberLe@rner22-Jan-20 19:19 
AnswerRe: how flip the canvas vertically ? Pin
Gerry Schmitz22-Jan-20 7:26
mveGerry Schmitz22-Jan-20 7:26 
QuestionAsp.net Pin
RajaMohammed.A22-Jan-20 1:35
MemberRajaMohammed.A22-Jan-20 1:35 
AnswerRe: Asp.net Pin
OriginalGriff22-Jan-20 2:29
mveOriginalGriff22-Jan-20 2:29 
AnswerRe: Asp.net Pin
Richard Deeming22-Jan-20 3:11
mveRichard Deeming22-Jan-20 3:11 
AnswerRe: Asp.net Pin
Gerry Schmitz22-Jan-20 7:37
mveGerry Schmitz22-Jan-20 7:37 
QuestionConvert the data intered by the user to integer number Pin
Member 906313820-Jan-20 22:37
MemberMember 906313820-Jan-20 22:37 
AnswerRe: Convert the data intered by the user to integer number Pin
OriginalGriff20-Jan-20 22:47
mveOriginalGriff20-Jan-20 22:47 
AnswerRe: Convert the data intered by the user to integer number Pin
ZurdoDev21-Jan-20 3:09
mveZurdoDev21-Jan-20 3:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.