pchalamet / cassandra-sharp

high performance .NET driver for Apache Cassandra
114 stars 41 forks source link

Huge improvements #71

Closed Virus-X closed 10 years ago

Virus-X commented 10 years ago

Hi! Thank you for this awesome lib. I'm using it in own project and I made some improvements to it. Maybe it's too much changes for one pull request.. if so, I can create few smaller ones.

Generally, all this changes make data binding much more flexible. And POCO, well.. now it's more like Entity. But you can use it in old way, if you wish, no code is necessary to be changed.

public class Shape
{
  public long Id {get;set;}
  public List<byte[]> Points {get;set;}
}

But now you have only to define CassandraTypeSerializer for Point class, and embed Point inside Shape. Data will be serialized transparently to blob and deserialized back, which leads to cleaner code and less frustration ;)

public class Shape
{
  public long Id {get;set;}
  public List<Point> Points {get;set;}
}

[CassandraTypeSerializer(typeof(PointSerializer))]
public class Point
{
  public int X {get;set;}
  public int Y {get;set;}
}

public class PointSerializer : ICassandraTypeSerializer ...

So, I think, that's all for now. I have plans to implement small library with Repository pattern in near future, that uses your library as backend (actually I have it, but it needs some cleanup).

pchalamet commented 10 years ago

Hi, sorry for the delay, I was quite busy this week. Let me review this and come back to you !

pchalamet commented 10 years ago

Thanks, I've merged your changes. One remark: could you implement unit tests for POCO attributes & DataMapper ?

Btw, could you contact me privately ? (pierre at chalamet dot net) Thanks.