dtretyakov / WindowsAzure

.NET library aimed at managing and querying entities from Windows Azure Storage. It can be used as LINQ to Azure Tables.
MIT License
64 stars 27 forks source link

Exception "Invalid entity member type:" is raised for properties tagged with [Ignore] #20

Closed mcora closed 11 years ago

mcora commented 11 years ago

I would expect type checking to be turned off for properties that are not supposed to be serialized.

dtretyakov commented 11 years ago

Thanks for posting. It'll be fixed in the next release. Also I found your use case with a TableEntityConverter and it'll be public in the upcoming version.

mcora commented 11 years ago

Thanks Dmitry, and nice work! I much prefer your extensions to the standard Azure Storage library, the code is so much cleaner.

dtretyakov commented 11 years ago

Fixed in commit https://github.com/dtretyakov/WindowsAzure/commit/c881f65fa1b8c37dbe1cebd9377e225606efbbe7

dtretyakov commented 11 years ago

Available in the nuget package v0.7.5.

mcora commented 11 years ago

I've upgraded to 0.7.5 but had to revert back to 0.7.2. All queries are throwing Invalid Operation, even for a simple one:

var table = new TableSet(_tableClient, Tables.DM_PROFILE); var query = table.Where( p => true ); var profiles = query.ToList();

dtretyakov commented 11 years ago

It looks like your POCO's attributes metadata is invalid. InvalidOperationException may occurs in the following cases:

[Ignore]
[Property("CustomName")]
public string MyProperty { get; set; }

Also for further investigation, could you post here exception message and stack trace?

mcora commented 11 years ago

This is a strange one.. I tried it again, and tracked down the root problem to the Query returning 0 elements, when the data is exists. This simple code works perfectly in version 0.7.2, but returns 0 elements in 0.7.5. It does not throw any exceptions:

public class MapFedid
{
    [PartitionKey]
    public string Context { get; set; }

    [RowKey]
    public string FederatedId { get; set; }
}

public MapFedid GetMapping(eUserContext context, string fedId)
{
    var table = new TableSet<MapFedid>(_tableClient, Tables.MAP_FEDERATED_ID);
    var query = table.Where(p => p.Context == context.ToString() && p.FederatedId == fedId);
    var results = query.ToList();
    return results.First();
}
dtretyakov commented 11 years ago

Thanks a lot for a complete code sample, just one moment: what type of eUserContext? Is it a enumeration or reference type? If it's a reference type, is it has an overloaded ToString method?

mcora commented 11 years ago

Yes, enumeration:

public enum eUserContext
{
    Unauthorized,
    VIP,
    DM,
    ADMIN,
}
dtretyakov commented 11 years ago

Thanks, it fixed in https://github.com/dtretyakov/WindowsAzure/commit/c3275a764f3a4e6b7d15ccf530fc123610ab5704

dtretyakov commented 11 years ago

Available in the nuget package v0.7.6.

mcora commented 11 years ago

Thanks, my integration tests succeed with 0.7.6, so far so good.

dvdstelt commented 9 years ago

I still have a problem with List which throws an exception before the EntityTypeMap is loaded.

dvdstelt commented 9 years ago
public class Foo
{
  public string PartKey { get; set; }
  public string RowKey { get; set; }
  public List<Bar> MyList { get; set; }
}

public class Bar
{
  public string SomeProp { get; set; }
}

public clsss FooMap : EntityTypeMap<Foo>
{
  this.PartitionKey(p => p.PartKey),
  .RowKey(p => p.RowKey),
  .Ignore(p => p.MyList);
}

Gives an exception