Nice! Well, you can always ask the good guys @uNHAddins to add this to their projects.
RP On May 9, 12:44 pm, Vagif Abilov <[email protected]> wrote: > Bingo! References(x => x.Category).Not.LazyLoad() did the trick. > > Thanks a lot for your help. > > On a related note: do you know why this code is not included in standard NH > release and only exists on the net in blog posts? Shouldn't this be rather > standard extension for NHibernate? > > Vagif > > > > > > > > On Mon, May 9, 2011 at 1:15 PM, Ricardo Peres <[email protected]> wrote: > > Vagif, > > > The error is related to having a proxy (Castle) instead of the object > > type it expects... > > Try to mark all entities as not lazy, or, at least, many to one > > associations, and see what happens! > > > RP > > > On May 9, 11:56 am, Vagif Abilov <[email protected]> wrote: > > > Hei Ricardo, > > > > I am using the implementation that is referenced in the comment above, > > and > > > while it works in most cases, there is a failure related to navigation > > > between related entities. > > > > If I use Northwind sample database where Categories and Products are in > > > one-to-many relationship, it only works on "one" side, e.g. > > > > writing Categories.Expand("Products") in LinqPad produces correct result. > > > writing Products.Expand("Category") causes the following error message: > > > > *The type 'Castle.Proxies.CategoriesProxy' is not a complex type or an > > > entity type. > > > * > > > Here are my class definitions: > > > > [DataServiceKey("CategoryID")] > > > public class Categories > > > { > > > public virtual int CategoryID { get; set; } > > > public virtual string CategoryName { get; set; } > > > public virtual string Description { get; set; } > > > public virtual byte[] Picture { get; set; } > > > > public virtual ICollection<Products> Products { get; set; } > > > } > > > > public class CategoriesMap : ClassMap<Categories> > > > { > > > public CategoriesMap() > > > { > > > Id(x => x.CategoryID).GeneratedBy.Increment(); > > > Map(x => x.CategoryName).Not.Nullable(); > > > Map(x => x.Description); > > > Map(x => x.Picture); > > > HasMany(x => x.Products) > > > .Table("Products") > > > .KeyColumn("CategoryID"); > > > } > > > } > > > > [DataServiceKey("ProductID")] > > > public class Products > > > { > > > public virtual int ProductID { get; set; } > > > public virtual string ProductName { get; set; } > > > public virtual int SupplierID { get; set; } > > > public virtual int CategoryID { get; set; } > > > public virtual string QuantityPerUnit { get; set; } > > > public virtual decimal? UnitPrice { get; set; } > > > public virtual short UnitsInStock { get; set; } > > > public virtual short UnitsOnOrder { get; set; } > > > public virtual short ReorderLevel { get; set; } > > > public virtual bool Discontinued { get; set; } > > > > public virtual Categories Category { get; set; } > > > public virtual Suppliers Supplier { get; set; } > > > public virtual ICollection<OrderDetails> OrderDetails { get; set; > > } > > > } > > > > public class ProductsMap : ClassMap<Products> > > > { > > > public ProductsMap() > > > { > > > Id(x => x.ProductID); > > > Map(x => x.ProductName).Not.Nullable(); > > > Map(x => x.SupplierID); > > > Map(x => x.CategoryID); > > > Map(x => x.QuantityPerUnit); > > > Map(x => x.UnitPrice); > > > Map(x => x.UnitsInStock); > > > Map(x => x.UnitsOnOrder); > > > Map(x => x.ReorderLevel); > > > Map(x => x.Discontinued).Not.Nullable(); > > > References(x => x.Category) > > > .Column("CategoryID"); > > > References(x => x.Supplier) > > > .Column("SupplierID"); > > > HasMany(x => x.OrderDetails) > > > .Table("[Order Details]") > > > .KeyColumn("ProductID"); > > > } > > > } > > > > You say relations must be entities or simple collections of entities.But > > > "Category" is an entity, what else can it be? I also tried changing from > > > ICollection to IList, but still the same error on "many" side of the > > > relation. > > > > Vagif > > > > On Mon, May 9, 2011 at 11:23 AM, Ricardo Peres <[email protected]> > > wrote: > > > > @object, > > > > You also must take some things in consideration: > > > > > - Relations must be entities or simple collections of entities > > > > (IList<T>, IEnumerable<T>), not sets (ISet<T>, HashSet<T>) or maps > > > > (IDictionary, IDictionary<K, V>, HashTable); > > > > - The ID property must be called either "ID", or end with "ID", for > > > > example, "CustomerID", otherwise you must apply the > > > > DataServiceKeyAttribute to the primary key property; > > > > - The ID property must have a public setter as well as a public > > > > getter; > > > > - The ID property must be of a basic type, such as int or string; > > > > - The collections to expose must be public properties of type > > > > IQueryable<T> or IOrderedQueryable<T>. > > > > > RP > > > > > On May 9, 2:17 am, José F. Romaniello <[email protected]> wrote: > > > > > I think this is newest: > > >http://weblogs.asp.net/cibrax/archive/2010/08/13/nhibernating-a-wcf-d... > > > > > > 2011/5/7, object <[email protected]>: > > > > > > > Hi, > > > > > > > I am trying to create an OData feed using NHibernate and I am > > confused > > > > > > about the information about its support of IUpdatable interface. > > I've > > > > > > found posts by Shawn Wildermuth about his implementation of > > IUpdatable > > > > > > interface for NH to support WCF Data Services ( > >http://wildermuth.com/ > > > > > > 2008/08/03/Implementing_IUpdatable_%28Part_3%29). There is also > > > > > > Ayende's post referring to this implementation. In comment to his 3 > > > > > > years old post Shawn suggests downloading NH LINQ to look at the > > > > > > sources. > > > > > > > But I haven't found anything related to IUpdatable in recent NH > > > > > > sources. There is not such interface referenced in NH solutions and > > > > > > projects. And on the net there are some sketches and samples, but > > no > > > > > > full implementation. > > > > > > > So if anyone knows the status of support for WCF Data Services by > > > > > > NHibernate, I will appreciate if you clarify this for me. Right now > > I > > > > > > don't really understand the state of this feature. > > > > > > > Thanks in advance. > > > > > > > -- > > > > > > You received this message because you are subscribed to the Google > > > > Groups > > > > > > "nhusers" group. > > > > > > To post to this group, send email to [email protected]. > > > > > > To unsubscribe from this group, send email to > > > > > > [email protected]. > > > > > > For more options, visit this group at > > > > > >http://groups.google.com/group/nhusers?hl=en. > > > > > > -- > > > > > Enviado desde mi dispositivo móvil > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "nhusers" group. > > > > To post to this group, send email to [email protected]. > > > > To unsubscribe from this group, send email to > > > > [email protected]. > > > > For more options, visit this group at > > > >http://groups.google.com/group/nhusers?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "nhusers" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > >http://groups.google.com/group/nhusers?hl=en. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
