Permalink
Browse files

laying framework for poco support

  • Loading branch information...
nberardi committed May 9, 2012
1 parent 1cb043b commit ab0995dfdf1bd94cfab5699786cd33e9e1328344
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using FluentCassandra.ObjectSerializer;
using FluentCassandra.Types;
namespace FluentCassandra
@@ -23,7 +24,10 @@ public partial class CassandraColumnFamily : BaseCassandraColumnFamily
private CassandraColumnFamilySchema _cachedSchema;
public CassandraColumnFamily(CassandraContext context, string columnFamily)
- : base(context, columnFamily) { }
+ : base(context, columnFamily)
+ {
+
+ }
public FluentColumnFamily CreateRecord(CassandraObject key)
{
@@ -33,6 +37,8 @@ public FluentColumnFamily CreateRecord(CassandraObject key)
return new FluentColumnFamily(key, FamilyName, GetSchema());
}
+ public ObjectSerializerConventions ObjectConventions { get; set; }
+
public override CassandraColumnFamilySchema GetSchema()
{
var schema = Context.Keyspace.GetColumnFamilySchema(FamilyName);
@@ -150,6 +150,8 @@
<Compile Include="IFluentBaseColumn.cs" />
<Compile Include="CassandraColumnFamilyOperations.cs" />
<Compile Include="IFluentRecordExpression.cs" />
+ <Compile Include="ObjectSerializer\ObjectSerializerConventions.cs" />
+ <Compile Include="Linq\CqlObjectQueryProvider.cs" />
<Compile Include="Linq\CqlQuery.cs" />
<Compile Include="Linq\CqlQueryEvaluator.cs" />
<Compile Include="Linq\CassandraColumnFamily+QueryProvider.cs" />
@@ -176,7 +176,7 @@ private CassandraObject GetColumnValue(object name)
return NullType.Value;
var schema = GetColumnSchema(name);
- return (CassandraObject)col.ColumnValue.GetValue(schema.ValueType);
+ return col.ColumnValue.GetValue(schema.ValueType);
}
/// <summary>
@@ -10,6 +10,11 @@ namespace FluentCassandra
{
public partial class CassandraColumnFamily : IQueryable, IQueryable<ICqlRow>, IQueryProvider
{
+ public CqlObjectQueryProvider<T> QueryWithObject<T>()
+ {
+ return new CqlObjectQueryProvider<T>(this);
+ }
+
public CqlQuery ToQuery()
{
var queryable = (IQueryable)this;
@@ -0,0 +1,100 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+
+namespace FluentCassandra.Linq
+{
+ public class CqlObjectQueryProvider<T> : IQueryable, IQueryable<T>, IQueryProvider
+ {
+ private readonly CassandraColumnFamily _family;
+
+ public CqlObjectQueryProvider(CassandraColumnFamily family)
+ {
+ _family = family;
+ }
+
+ #region IQueryable Members
+
+ /// <summary>
+ /// Gets the type of the element(s) that are returned when the expression tree associated with this instance of <see cref="T:System.Linq.IQueryable"/> is executed.
+ /// </summary>
+ /// <value></value>
+ /// <returns>
+ /// A <see cref="T:System.Type"/> that represents the type of the element(s) that are returned when the expression tree associated with this object is executed.
+ /// </returns>
+ public virtual Type ElementType
+ {
+ get { return typeof(T); }
+ }
+
+ /// <summary>
+ /// Gets the expression tree that is associated with the instance of <see cref="T:System.Linq.IQueryable"/>.
+ /// </summary>
+ /// <value></value>
+ /// <returns>
+ /// The <see cref="T:System.Linq.Expressions.Expression"/> that is associated with this instance of <see cref="T:System.Linq.IQueryable"/>.
+ /// </returns>
+ Expression IQueryable.Expression
+ {
+ get { return Expression.Constant(this); }
+ }
+
+ /// <summary>
+ /// Gets the query provider that is associated with this data source.
+ /// </summary>
+ /// <value></value>
+ /// <returns>
+ /// The <see cref="T:System.Linq.IQueryProvider"/> that is associated with this data source.
+ /// </returns>
+ IQueryProvider IQueryable.Provider
+ {
+ get { return this; }
+ }
+
+
+ #endregion
+
+ #region IEnumerable Members
+
+ public System.Collections.IEnumerator GetEnumerator()
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+
+ #region IEnumerable<T> Members
+
+ IEnumerator<T> IEnumerable<T>.GetEnumerator()
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+
+ #region IQueryProvider Members
+
+ public IQueryable<TElement> CreateQuery<TElement>(Expression expression)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IQueryable CreateQuery(Expression expression)
+ {
+ throw new NotImplementedException();
+ }
+
+ public TResult Execute<TResult>(Expression expression)
+ {
+ throw new NotImplementedException();
+ }
+
+ public object Execute(Expression expression)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace FluentCassandra.ObjectSerializer
+{
+ public class ObjectSerializerConventions
+ {
+ public ObjectSerializerConventions()
+ {
+ AreKeyPropertyNamesCaseSensitive = false;
+ KeyPropertyNames = new List<string>(new[] { "Key", "Id" });
+ }
+
+ public bool AreKeyPropertyNamesCaseSensitive { get; set; }
+ public List<string> KeyPropertyNames { get; set; }
+ }
+}

0 comments on commit ab0995d

Please sign in to comment.