Dynamic Linq help, different errors depending on the object passed as a parameter?

I have an entityDao that is inherited by all my Daos objects. I am using Dynamic Linq and trying to get some common queries to work.

I have the following code in my generic method in my EntityDao:

public abstract class EntityDao<ImplementationType> where ImplementationType : Entity
{ 
    public ImplementationType getOneByValueOfProperty(string getProperty, object getValue){
    ImplementationType entity = null;
    if (getProperty != null && getValue != null) 
    {
        LCFDataContext lcfdatacontext = new LCFDataContext(); 
         //Generic LINQ Query Here
         entity = lcfdatacontext.GetTable<ImplementationType>().Where(getProperty + " =@0", getValue).FirstOrDefault();
         //.Where(getProperty & "==" & CStr(getValue))
     }

 //lcfdatacontext.SubmitChanges()
 //lcfdatacontext.Dispose()

return entity;
}

Then I call the following method call in unit test (my entire ObjectDaos object inherits entityDao):

[Test]
public void getOneByValueOfProperty()
{
    Accomplishment result = accomplishmentDao.getOneByValueOfProperty
        ("AccomplishmentType.Name", "Publication");

    Assert.IsNotNull(result);
}

The above omissions (AccomplishmentType is related to achievement)

Accomplishment result = accomplishmentDao.getOneByValueOfProperty("Description", "Can you hear me now?");
Accomplishment result = accomplishmentDao.getOneByValueOfProperty("LocalId", 4);

Both of these work. Nonetheless,

 Accomplishment result = accomplishmentDao.getOneByValueOfProperty
    ("Id", New Guid("95457751-97d9-44b5-8f80-59fc2d170a4c"));

It does not work and says the following:

Operator '=' incompatible with operand types 'Guid' and 'Guid

Why is this happening? Can't the guide compare? I also tried ==, but the same error. What is even more confusing is that in each Dynamic Linq example I just saw lines using the parameter where the predicate or this one I commented out:

//.Where(getProperty & "==" & CStr(getValue))

Cstr . getValue , (, ).

, GUID / ? getValue ( LINQ) .

+5
2

Welp , Dynamic LINQ GUID ( !). : https://connect.microsoft.com/VisualStudio/feedback/details/333262/system-linq-dynamic-throws-an-error-when-using-guid-equality-in-where-clause

Dynamics.cs, IEqualitySignatures :

interface IEqualitySignatures : IRelationalSignatures
{
    void F(bool x, bool y);
    void F(bool? x, bool? y);
    void F(Guid x, Guid y);
    void F(Guid? x, Guid? y);
}

getOneByValueOfProperty !

+6

Guid :

.Where(getProperty + ".Equals(@0)", getValue);

( , getValue Guid)

0

All Articles