Giter VIP home page Giter VIP logo

graphdiff's People

Contributors

b9chris avatar dzmitrymikhalap avatar jonathanmagnan avatar lempireqc avatar mrjackdavis avatar refactorthis avatar waqasm78 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphdiff's Issues

"The relationship could not be changed because one or more of the foreign-key properties is non-nullable"

Why am I getting this EF exception when removing a child from an owned collection?

"The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted."

More of a question/comment

I wrote a set of extensions that will generate a GraphNode without a mapping. Currently it passes 24 tests and fails on 4. Of the 4 failing tests 3 of them relate to Removing Entities from the context when their navigation values are null. I think that this ok because without the mapping I do not have a way of knowing what null navigations are actually removals. I am not sure how to submit my changes for someone to review, or if your even interested in something like this.

Base Entity updates all fields even if there are no changes

Child entities seem to get updates only on fields that were changed. Can the project be changed so that the base entity only does an update IF there are changes, and only to fields that have changed?

EDIT---
Turns out this is a bug in the code. In 2 places you do:

        context.Entry(existing).CurrentValues.SetValues(entity);
        context.Entry(existing).State = EntityState.Modified;

You don't need the second line. That marks the whole object as changed. If you comment that out in 2 places, then the base entity updates properly.

Sean

NuGet package is still at version 1.3.6 and needs to be updated

I have a graph:

context.UpdateGraph(parent, 
                    uc=>uc
                        .OwnedCollection(j=>j.ChildItems, with=>with.OwnedCollection(i=>i.GrandChildItems))
                        .AssociatedEntity(j=>j.FirstAssociatedItem)
                        .AssociatedEntity(j=>j.AnotherAssociatedItem)
                        );

and I get the following exception when using the nuget package:

   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__3[TResult](IEnumerable`1 sequence)
   at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
   at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
   at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
   at System.Linq.Queryable.Single[TSource](IQueryable`1 source, Expression`1 predicate)
   at RefactorThis.GraphDiff.DbContextExtensions.FindEntityMatching[T](DbContext context, T entity, String[] includes)
   at RefactorThis.GraphDiff.DbContextExtensions.UpdateGraph[T](DbContext context, T entity, Expression`1 mapping)

So I downloaded the source and added to my solution to debug the issue, however everything works fine and the code seems vastly different from the stack trace so I was unable to trace the issue.

Could the NuGet package be updated please?

Thanks

Member 'CurrentValues' cannot be called for the entity

I have the following:

  • Client
  • Client >> List CompetencyCertificates
  • CompetencyCertificate >> List CompetencyTypes

I load a client object from the database, and then assign new List values to the List members mentioned above.

Subsequently, I call the following code:

dbContext.UpdateGraph(client, map => map
                .OwnedCollection(cc => cc.CompetencyCertificates, with => with
                    .AssociatedCollection(kt => kt.CompetencyTypes))
                );

dbContext.SaveChanges();

Here is the stacktrace for the exception that gets thrown on the UpdateGraph invocation:

Member 'CurrentValues' cannot be called for the entity of type 'CompetencyCertificate' because the entity does not exist in the context. To add an entity to the context call the Add or Attach method of DbSet<CompetencyCertificate>.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Member 'CurrentValues' cannot be called for the entity of type 'CompetencyCertificate' because the entity does not exist in the context. To add an entity to the context call the Add or Attach method of DbSet<CompetencyCertificate>.

Source Error: 


Line 138:
Line 139:            //UPDATE GRAPH OF DETACHED ENTITIES
Line 140:            dbContext.UpdateGraph(client, map => map
Line 141:                .OwnedCollection(cc => cc.CompetencyCertificates, with => with
Line 142:                    .AssociatedCollection(kt => kt.CompetencyTypes))

Source File: [Not Important]   Line: 140 

Stack Trace: 


[InvalidOperationException: Member 'CurrentValues' cannot be called for the entity of type 'CompetencyCertificate' because the entity does not exist in the context. To add an entity to the context call the Add or Attach method of DbSet<CompetencyCertificate>.]
   System.Data.Entity.Internal.InternalEntityEntry.ValidateNotDetachedAndInitializeRelatedEnd(String method) +102
   System.Data.Entity.Internal.InternalEntityEntry.ValidateStateToGetValues(String method, EntityState invalidState) +55
   System.Data.Entity.Internal.InternalEntityEntry.get_CurrentValues() +53
   System.Data.Entity.Infrastructure.DbEntityEntry.get_CurrentValues() +44
   RefactorThis.GraphDiff.DbContextExtensions.RecursiveGraphUpdate(DbContext context, Object dataStoreEntity, Object updatingEntity, UpdateMember member) +942
   RefactorThis.GraphDiff.DbContextExtensions.UpdateGraph(DbContext context, T entity, Expression`1 mapping) +631
   JCGunsOnline.Controllers.ClientController.SaveClientProfile() in c:\Users\Ben\Dropbox\Mighty IT\Active Projects\JCGunsOnline\JCGunsOnline\Views\Client\ClientController.cs:140
   JCGunsOnline.Controllers.ClientController.SubmitStep1() in c:\Users\Ben\Dropbox\Mighty IT\Active Projects\JCGunsOnline\JCGunsOnline\Views\Client\ClientController.cs:60
   lambda_method(Closure , ControllerBase , Object[] ) +101
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +59
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +435
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +60
   System.Web.Mvc.Async.ActionInvocation.InvokeSynchronousActionMethod() +76
   System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +36
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +117
   System.Web.Mvc.Async.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() +323
   System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +44
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +72
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +39
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514928
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Correct way of configuring "grand-children"?

What is the correct way of configuring "grand-children"? Are they already supported? Every odd time I am updating the root object, GraphDiff deletes them.

My root business object:

public class Package
{
    public Package()
    {
        Applications = new List<Application>();
        ApplicationParts = new List<ApplicationPart>();
        Actions = new List<Action>();
        Reports = new List<Report>();
    }

    public List<ApplicationPart> ApplicationParts { get; set; }
    public List<Application> Applications { get; set; }
    public List<Action> Actions { get; set; }
    public List<Report> Reports { get; set; }
}

My update config:

uc => uc.OwnedCollection(p => p.Applications)
        .OwnedCollection(p => p.Applications, m => m.OwnedCollection(a => a.Actions))
        .OwnedCollection(p => p.Applications, m => m.OwnedCollection(a => a.Reports))
        .OwnedCollection(p => p.ApplicationParts)
        .OwnedCollection(p => p.Actions)
        .OwnedCollection(p => p.Reports);

Thank you.

Can't save new entity when its parent property is assigned

I originally posted this on your blog, but thought it best to post here in case you no longer monitor your blog comments...

I’m having a problem with GraphDiff. I have these entities (generated using the EF5 POCO template, database-first):-

public partial class Customer
{
public int Id { get; set; }
public virtual ICollection Orders { get; set; }
// other properties…
}

and

public partial class Order
{
public int Id { get; set; }
public int CustomerId { get; set; }
public virtual Customer Customer { get; set; }
public virtual ICollection OrderLines { get; set; }
// other properties…
}

Now for my code. I retrieve an existing customer, add a new order (while detached), then save changes:-

using (var context = new MyTestEntities())
{
customer = context.Customers.First(o => o.Id == 1);
} // Simulate disconnect

var newOrder = new Order { Customer = customer }; // See below
customer.Orders.Add(newOrder);

using (var context = new MyTestEntities())
{
context.UpdateGraph(customer, m1 => m1.OwnedCollection(o => o.Orders));
context.SaveChanges();
}

However SaveChanges() throws the exception “Multiplicity constraint violated. The role ‘Customer’ of the relationship ‘MyTestModel.FK_Order_Customer’ has multiplicity 1 or 0..1″. It seems to be because I'm setting the new order’s “Customer” property. If I remove this assignment then the code works.

In "vanilla" implementations of EF it's normal to fix up both sides of a relationship in this manner, and is often a necessity. Am I doing something wrong? I admit I don't really understand the difference between “owned” and “associated”, so perhaps I'm doing something wrong when calling UpdateGraph()?

Null values in entity should not be passed to DB - option to ignore them

In a distributed scenario we often get data as use-case-optimized DTOs.
Then we are mapping them onto internal entities. If we use UpdateGraph and the 'internal' entity has null values (which is quite common after mapping from a DTO) the database is updated with null values (or records are even deleted...)

We really need an option to consider this scenario.

Possible EF 5.0 Issue

Brent,

First off thanks so much for the library! I'm not sure if I have something configured wrong but here is my situation. I was attempting to use the GraphDiff - Entity Framework Graph auto-update NuGet Package 1.3.4 on a project that was also using the EF 5.0 NuGet Package. Also, I'm not sure if this is pertinent information or not but we are hosting our data access layer in a WCF Service. My issue was I was getting a conflicting assembly version warning and when I built the app and when I ran the app it would tell me that GraphDiff could not find the EF 4.3.1 assembly that it depends on. This happened as soon as I tried to run any .UpdateGraph() code. I found some code wrapped in a unit test (link below) that displays any assemblies that may have conflicts and sure enough in my DataAccess project showed dependencies for both EF 4.3.1 and EF 4.4 The GraphDiff packaged was expecting EF 4.3.1 and my project was using EF 5 but because it targets the .Net 4.0 Framework EF uses the 4.4 assembly version. The GraphDiff Nuget package shows that it is dependent on EF (greater than or equal to 4.3.0) so I wasn't expecting this to be an issue. Maybe it's because we are targeting the .Net 4.0, I'm not sure. In any event in order to get it to work I had to download the GraphDiff source code and upgrade the EF NuGet package it was using from 4.3.1 to 5.0. Then I ran all tests and built a new dll in Release. As long as I reference the compiled DLL it seems to work fine. I don't know if there is a way to configure or manage this type of issue when building the NuGet Package but I thought I'd let you know about this experience.
Regards

https://gist.github.com/brianlow/1553265

Multiplicity constraint violated - am I doing something wrong?

Hi
I've only just started experimenting with GraphDiff and I've hit a problem (it's probably due to the way I'm using it) - can anyone help?

My database is setup like this:

2014-02-04_1048

I want to open blogpost 1, add a comment to it (by the author of the blogpost) and then save it.

My code is -

        BlogPost blogpost;

        using (TestEntities te = new TestEntities())
        {
            //retrieve blog post 1, with all comments and authors
            //(so we can display the entire record on the UI while we are disconnected)
            blogpost = te.BlogPosts
                .Include("Comments")
                .Include("Comments.Author")
                .Include("Author")
                .SingleOrDefault(i => i.ID == 1);
        }

        //add the comment
        blogpost.Comments.Add(new Comment()
        {
            Content = "New comment",
            Author = blogpost.Author
        });

        //attempt to save
        using (TestEntities te = new TestEntities())
        {
            te.UpdateGraph(blogpost,
                map => map
                    .OwnedCollection(i => i.Comments)
                );
            te.SaveChanges();
        }

On the .SaveChanges() I get the following error - "Multiplicity constraint violated. The role 'BlogPost' of the relationship 'TestModel.FK__Comment__PostID__03BB8E22' has multiplicity 1 or 0..1."

Can anyone help? Thanks

Attributes

Hi,

In NHibernate, it's possible to update a detached graph using annotation attributes to specify whether a certain property is owned or associated.

I think it would be great to have the flexibility of using attributes instead of remapping the fluent API over on each update.

Thanks!

Generic Repository and Concurrency

First of all congratulations for your extension method.
My questions are the following:

  1. I downloaded the latest version (1.3.6) package for my Generic Repository and I replaced the part concerning the Update:
    using RefactorThis.GraphDiff;

namespace DAL
{
public class GenericRepository : IGenericRepository where T : class, IEntityWithId
{
private MyContext ctx;
private readonly DbSet dbSet;
public GenericRepository(MyContext context)
{
ctx = context;
dbSet = ctx.Set();
//disable LazyLoading and Proxy
ctx.Configuration.LazyLoadingEnabled = false;
ctx.Configuration.ProxyCreationEnabled = false;
}

    public void Update(T entityToUpdate)
    {
        ctx.UpdateGraph(entityToUpdate);
    }

    /*
    public void Update(T entityToUpdate)
    {
        var entry = ctx.Entry<T>(entityToUpdate);

        if (entry.State == EntityState.Detached)
        {
            var set = ctx.Set<T>();

            T attachedEntity = set.Find(entityToUpdate.ID);

            if (attachedEntity != null)
            {
                ctx.Entry<T>(attachedEntity).CurrentValues.SetValues(entityToUpdate);
            }
            else
            {
                entry.State = EntityState.Modified;
            }
        }
    }
    */

With great enthusiasm I noticed that in every Form of my application, updates to work correctly.
However when I create a situation where you might expect a concurrency conflict, I get the following error:

An unhandled exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in RefactorThis.GraphDiff.dll

Additional information: RowVersion failed optimistic concurrency

In my Model in Code First is however a line for managing concurrency (Timestamp).

  1. I downloaded the source code directly from the site https://github.com/refactorthis/GraphDiff/(Download ZIP) but once compiled, I noticed that this is no longer the 1.3.6 version but a version next time, I think it's the future 1.4.0
    With this version, I can no longer compile the row currently ctx.UpdateGraph (entityToUpdate).
    Perhaps it should be error caused by the Abstract Class but I did not understand.

Nested entity

My class structure looks like this (EF Code-First):

class Document {
public int Id { get; set; }
public ICollection<DocumentDetail> DocumentDetails { get; set; }
}

public class DocumentDetail
{
public int Id { get; set; }
public Nomenclature Nomenclature { get; set; }
public int Quantity { get; set; }
public decimal Price { get; set; }
public decimal Sum { get; set; }
}

public class Nomenclature
{
public int Id { get; set; }
public string Name { get; set; }
}

Document entity has one-to-many relationship with the entity DoсumentDetail which has a one to one relationship with the Nomenclature entity. This entity created as a result of user actions so it deattached and save code looks like this:

_session.DbContext.UpdateGraph(document,
map =>
map.OwnedCollection(c => c.DocumentDetails, with => with.AssociatedEntity(e => e.Nomenclature))
);

In this case, all is well, except in the Nomenclature entity, it is always inserted into the table as a new record, although specified identifier must be an existing record. This happens no matter what method I use AssociatedEntity or OwnedEntity

Use internal property as primary key

If I try to use internal property as primary key I get null reference exception, because GetPropety metod doesn't return any internal property

return metadata.KeyMembers.Select(k => entityType.GetProperty(k.Name)).ToList();

It´s Thread safe?

Hi Guys,

In few months ago, I had reference the GraphDiff and it´s amazing, however now I need to change the save action to an async mode, but first I would like to know if GraphDiff is Thread safe, Because a will want to call "UpdateGraph" before the SaveChangesAsync.

It´s possible?

Thanks in advance!

PS: This feature should be added by EF....

Possible bug when the same entity is to be updated in more than one association

Hi,

updating an association-heavy (including multiple associations to a single entity) seems to not work as expected. After the following call to UpdateGraph

container.UpdateGraph(block, map => map
        .OwnedCollection(b => b.CalcPoints)
        .OwnedCollection(b => b.PerfModes, w => w
            .OwnedCollection(p => p.FilterCriterion, w2 => w2
               .OwnedCollection(fc => fc.Filters, w3 => w3
                   .AssociatedEntity(f => f.CalcPoint))))
        .AssociatedCollection(p => p.CalcPoints)
);

the owned collection CalcPoints and the associated entity CalcPoint are correctly updated, but the associated collection CalcPoints (last line) is not.

This came up via stackoverflow and there is a gist with the complete code including a failing unit test.

Doesn't work with EF6

This error occurs when running entity framework 6 alpha 1

System.MissingMethodException: Method not found: 'Void System.Data.Entity.Infrastructure.DbEntityEntry`1.set_State(System.Data.EntityState)'.
   at GraphDiff.DbContextExtensions.UpdateGraph[T](DbContext context, T entity)

New reference while updating/saving entities

Hello,

I'm currently working on an wpf mvvm application. During start up I load existing entities from the db. During lifetime, this entities changes and should be saved in the background to the database, depending on some conditions (maybe every x minutes).

The model looks like:
MainEntitiy <-> ChildEntity <-> GrandChildEntity

This structure is used in several view models at different hierarchy levels. (e.g. ChildEntity is used in one view model, but accesses MainEntity or GrandChildEntity). Actually it doesn't matter.

When I try to save a MainEntity with UpdateGraph and map the full hierarchy with OwnedEntity/Collection then everything looks fine in the first place.

The problem (in a application environment) is the new reference of the entity which is returned by UpdateGraph method. The old, existing references, used in view models, are no longer valid. What would fix the problem is loading everything new, which most obvious, isn't the best way.

Maybe my understanding of UpdateGraph is wrong. Can you explain why this new behavior was introduced and how it's supposed to work correctly? in he 1.3.6, the old reference was still valid.

With best regards,
Stefan

UpdateConfigurationVisitor fix

Currently, if the root.IncludeString is null then GraphDiff blows chow. A simple fix to include a null check fixes the issue.

internal static class EFIncludeHelper
{
public static List GetIncludeStrings(UpdateMember root)
{
var list = new List();

        if (root.Members.Count == 0 && root.IncludeString != null)
        {
            list.Add(root.IncludeString);
        }

        foreach (var member in root.Members)
        {
            list.AddRange(GetIncludeStrings(member));
        }
        return list;
    }
}

Feature Discussion

No bug to report, just have a couple features I'm considering putting together, want to get feedback before I proceed.

  1. It's common in MVC to load an entity for Edit or Details, using some .Include(...) calls like:

db.Employees
.Include(e => e.ContactInfos)
.Include(e => Addresses)
.Single...

Then save it back in the post call, at which point you write more code to say the same thing to EFGraphDIff:

db.UpdateGraph(employee, x => x
.OwnedCollection(e => e.ContactInfos)
.OwnedCollection(e => e.Addresses);

Obviously in these kinds of simple CRUD controller cases it would be nice to say what Collections to Include once as you instantiate a helper class, and have Load and Save methods there that use that list of Collections. This lets you churn out EF-based MVC Controllers that truly load and save without a bunch of extra non-DRY coding, and you can change the underlying Models without regenerating the Controllers.

I've started to build the helper class above, but I ran into an issue where what EFGraphDiff is really looking for is a bunch of Expressions - is there a simpler way to dynamically set the list of OwnedCollections than to much with creationg a bunch of Expression.Body?

  1. Since UpdateGraph loads the existing object(s) from the db, it would be nice to have an Async TPL method:

public Task UpdateGraphAsync(...

Don't know if either of these are already on the radar, desired, etc. Happy to take a swing at either or both, advice welcome.

Nuget 2.0.0 package contains version 1.3.6 assembly

Hi Brent,

I have noticed that the nuget package for version 2.0.0 still contains the old assembly for version 1.3.6. I have double checked it with decompiler.

Can you please fix this? The new version works great for for me.

Thank you!
Stefan

Null ptr exception

HI.

I'm getting a null ptr exeception with this stack trace:

System.NullReferenceException: Object reference not set to an instance of an object.
at RefactorThis.GraphDiff.DbContextExtensions.EnsureConcurrency(DbContext db, T from, T to)
at RefactorThis.GraphDiff.DbContextExtensions.UpdateGraph(DbContext context, T entity, Expression`1 mapping)

Trying to investigate the problem I look at the class DbContextExtensions in the source code, but cannot find EnsureConcurrency().
Looking at the de-compiled source code, the implementation of DbContextExtensions is vastly different from the one in the source.

What could be the problem here and how to investigate?

Do not require a public parameterless ctor

Hi,

UpdateGraph requires entity type to have a visible parameterless ctor. This is not needed by EF, a protected parameterless ctor does the job.
I think you could remove the new() constraint and use Activator.CreateInstance<T>()

Support for adding new root entites

Thanks for this cool library. However, I think some very important port is missing: It does not solve the problem of adding an aggregation root entity respecting already existing related entites.

To illustrate, consider this model:
model

And the following Save method in a CustomerController:

public void Save()
{
    using (var dataContext = new TwoTierWpfAndEfContext())
    {
        if (customer.Id == 0)
        {
            // causes existing Address or Contact to be added a second time
            dataContext.Customers.Add(customer);

            // would be nice, but does not exist
            dataContext.AddGraph(customer, map => map.OwnedCollection(c => c.Contacts)
                                                        .OwnedCollection(c => c.Addresses, with => with.AssociatedEntity(add => add.Country)));
        }
        else
        {
            dataContext.UpdateGraph(customer, map => map.OwnedCollection(c => c.Contacts)
                                                                .OwnedCollection(c => c.Addresses, with => with.AssociatedEntity(add => add.Country)));
        }

        dataContext.SaveChanges();
    }
}

So, what do you think? Is it possible to solve it his way?

If a sun has more than one list?

Hi!,
First of all, Thanks for sharing this amazing and easy peace of code. It´s make me like a little more on EF, However I have a doubt, imagine That I have a Company with a list of contacts and each one of this contacts has 2 lists like Addresses and Phones,
Basic, if it was just on list inside contacts that will be:

using ( var db = new Context()) 
{
    db.UpdateGraph(cia, map => map.OwnedCollection(p => p.Contacts, m => m.AssociatedCollection(x => x.Phones)));
}

But How to put in a situation like a contact with 2 lists (Phones AND Addresses)?

Thanks in advance!

Models with a Base Class Fail if the Model (a subclass) is what's really in the DbSet

To make this easier to see, I've forked the repo and written a failing unit test:
https://github.com/b9chris/GraphDiff

Suppose:

Model class BaseContactInfo
Model class ContactContactInfo : BaseContactInfo
in DbContext: IDbSet ContactInfos

So, the subclass (ContactContactInfo) is what's actually attached to the DbContext, not the base class. GetKeysFor() calls GetFirstBaseType() without checking to see which class is actually tied to the DbContext (in fact, it's possible both are), and then asks the DbContext for the base class's DbSet - which in this case, there is none. That throws an Exception inside a yield IEnumerable, several methods deep in recursion - pretty hard for calling code to debug.

I have some guesses at how to fix this, although I noticed the several passing tests for Manager/Employee, where Manager is a subclass of Employee and is itself mapped directly to the DbContext, so I'm a bit confused as to why exactly this fails but those tests pass - perhaps a difference in how they're being used, or maybe the fact these ContactContactInfo classes are stored in a List.

Abstract class inheritance

When Entity classes, for example Post and Tag inherit from one abstract class like EntityBase which holds the definition for Id, the UpdateGraph(entity, map => map.AssociatedCollection(p => p.SomeList)); throws an Exception

Part of message from exception
Mapping and metadata information could not be found for EntityType 'ConsoleApplication2.Base'.

Does not currently work with proxy objects.

Need to add a quick fix for context.Set<dbItem.getType()>. If the current type is a proxy wrapped entity then this will not work.

Need to use:
ObjectContext.GetObjectType(dbItem.GetType()) instead.

Problem with internal navigation properties

In a one to many relationship where the child object has an internal navigation property to the parent, AttachRequiredNavigationProperties fails with a NullReferenceException.

protected static void AttachRequiredNavigationProperties(DbContext context, object updating, object persisted)
{
    var entityType = ObjectContext.GetObjectType(updating.GetType());
    foreach (var navigationProperty in context.GetRequiredNavigationPropertiesForType(updating.GetType()))
    {
        var navigationPropertyInfo = entityType.GetProperty(navigationProperty.Name);
               var associatedEntity = navigationPropertyInfo.GetValue(updating, null);
        if (associatedEntity != null)
        {
            associatedEntity = FindEntityByKey(context, associatedEntity);
        }

        navigationPropertyInfo.SetValue(persisted, associatedEntity, null);
    }
}

System.InvalidCastException in UpdateGraph when creating the lambda expression by code.

I have a class Mission with a property Detail.
When i run this code it works:

Expression<Func<IUpdateConfiguration<Mission>, dynamic>> exp = map => map.OwnedEntity(x => x.Detail);
dbContext.UpdateGraph(mission, exp);

but this code

 Expression<Func<Mission, MissionDetail>>  lambda = (x => x.Detail);
 Expression<Func<IUpdateConfiguration<Mission>, dynamic>> exp = map => map.OwnedEntity(lambda);
 dbContext.UpdateGraph(mission, exp);

will generate the following error

System.InvalidCastException : Unable to cast object of type 'System.Reflection.RtFieldInfo' to type 'System.Reflection.PropertyInfo'

GraphDiff does not work with EF 6.1.0

I'm using EF 6.1.0 with .NET 4.00 and GraphDiff 1.2(I installed it from Nuget) with a console application,
when I call the UpdateGraph method, This error occured:
System.MissingMethodException was unhandled
HResult=-2146233069
Message=Method not found: 'Void System.Data.Entity.Infrastructure.DbEntityEntry1.set_State(System.Data.EntityState)'. Source=GraphDiff StackTrace: at GraphDiff.DbContextExtensions.UpdateGraph[T](DbContext context, T entity, Expression1 mapping)
at AggregationRootUpdateTest.Program.Main(String[] args) in e:\Users\8060509\Documents\Visual Studio 2012\Projects\AggregationRootUpdateTest\AggregationRootUpdateTest\Program.cs:line 60
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Three Unit Tests Failing

AssociatedEntityValuesShouldNotBeUpdated() fails on

project.LeadCoordinator.FirstName = "Larry";

because LeadCoordinator is null.

AssociatedEntityWherePreviousValueWasNull() fails on

project = context.Projects
.Include(p => p.LeadCoordinator)
.Single(p => p.Id == 1);

with error "Sequence contains no elements"

OwnedEntityUpdateValues() fails on

project.LeadCoordinator.FirstName = "Tada";

because LeadCoordinator is null.

Add support for lists of primitives

Hi
I can't get many-to-many relation to update. Does it suppose to work?

I have wo questions:

  1. Just to be sure - What is difference between Associated and Owned? (I assumed Associated is correct for situation that a data points another one but the other data should not get deleted when the pointing data is deleted).
  2. Is there any problem when you use ForeignKey on properties? I suspect that GraphDiff doesn't detect situations where a property is actually binded through a ForeignKey property... (The foreign key property is actually a kind of proxy)...

What am I wrong?

In my application I use a Generic Repository:
namespace DAL
{
public class GenericRepository : IGenericRepository where T : class
{
private MyContext ctx;
private readonly DbSet dbSet;
public GenericRepository(MyContext context)
{
ctx = context;
dbSet = ctx.Set();

        ctx.Configuration.LazyLoadingEnabled = false;
        ctx.Configuration.ProxyCreationEnabled = false;
    }
    public T Find(int id)
    {
        return dbSet.Find(id);
    }
    public void Update(T entityToUpdate)
    {
        var entry = ctx.Entry<T>(entityToUpdate);

        if (entry.State == EntityState.Detached)
        {
            var set = ctx.Set<T>();

            T attachedEntity = set.Find(entityToUpdate.ID);

            if (attachedEntity != null)
            {
                ctx.Entry<T>(attachedEntity).CurrentValues.SetValues(entityToUpdate);
            }
            else
            {
                entry.State = EntityState.Modified; // attach the entity
            }
        }
    }

However, in a disconnected scenario, with my code, I can't handle the concurrency. Then I replaced the Update with:

public void Update(T entityToUpdate)
{
ctx.UpdateGraph(entityToUpdate);
}
But the compiler throws an error me reporting that: " 'T' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'RefactorThis.GraphDiff.DbContextExtensions.UpdateGraph "

Before moving on to the compiler version 2.0.1 did not give me this kind of error. What am I correct?

Merge on Unique Key (not Primary Key)

For synchronisation purpose sometimes we add a GUID column with an unique constraint but keep an autoinc int PKEY for regular work (avoiding fragmentation, unreadable keys,...).
If we could specify the column(s) on which the equality should be done during merge that would be great.

Context.UpdateGraph(document, map => map.OwnedCollection(d => d.Lines, withKey : line => line.UniqueId));

Without it, GraphDiff removes and re-adds the lines instead of updating them.

Documentation

Hi and thanks for this awesome library.

Please add documentation on all the public methods.

Sequence contains no elements error

I receive a "Sequence contains no elements" on the execution of the below code. Note that some of the lists referred to are empty (but not null):

 //UPDATE GRAPH OF DETACHED ENTITIES
            //JCGunsDb.Clients.Attach(client);
            JCGunsDb.UpdateGraph(client, map => map
                            .OwnedCollection(ci => ci.CrimeIncidents)
                            .OwnedCollection(cc => cc.CompetencyCertificates, with => with
                                .AssociatedCollection(kt => kt.WeaponTypes))
                            .OwnedCollection(tc => tc.TrainingCourses, with => with
                                .AssociatedCollection(tt => tt.TrainingTypes)
                                .AssociatedCollection(ta => ta.TrainingActivities))                            
                            .OwnedCollection(mem => mem.Memberships, with => with
                                .AssociatedEntity(mt => mt.MembershipType))                                                
                            );

Disconnected Complex Graph With Disconnected Child Entities

I have a complex graph with a collection child entities.The relationship between parent and child entities is one-many relationship and has an Independent association. I know that I cant persist my graph without manual synchronization which I want to avoid. I found your solution promising and I started exploring it but I couldn't achieve what I intend to as my scenario is somewhat peculiar.

public class person
{
    public virtual int Id {get; set;} //primary key
    public virtual string Name {get; set;}
    public virtual ICollection<Car> Cars {get; set;}
 }
public class Car
{
    public virtual int PersonId {get; set;} // is a foreign key 
    public virtual Datetime BoughtDate {get; set;}   // this property and above mentioned foreign key together makes a primary key in database

    public virtual DateTime InsuraceStartDate {get; set;}
    public virtual DateTime InsuraceExpiryDate {get; set;}
    public virtual DateTime LastServiceDate {get; set;}
}

At any given time my Person.Cars collection may have

  1. A new car object.

  2. An existing car object with updated values.(insurance or service dates).

    Id property on Person and PersonId on Car will be 0.

    Person _person = GetPersonToAddOrUpDate();
     int id =   _person.id; //id will be 0.
    

    At this point we are not sure the object we received has to added or updated. PersonId on child entities(Cars) will also be 0.Now if we call.

     Context.UpdateGraph(_person, m => m.OwnedCollection(x => x.Cars)); 
    

    throws exception at FindEntityMatching(entity).

    To overcome this I have to update Id property on person.

       var dbPersonId  = Context.Single<Person>(x => x.Name == _person.Name).Id;
      _person.id = dbPersonId != null ? dbPersonId : 0;
       Context.UpdateGraph(_person, m => m.OwnedCollection(x => x.Cars));
    

    It deletes all entities in dbPerson.Cars and adds _person.Cars to dbPerson.Cars and saves. It means all records in my Cars table in database are deleted and records from _person.Cars are inserted. I noticed this is happening because Now the child entities does not have a Id property. I have to set them manually.

    foreach(var car in _person.Cars)
          car.PersonId = _person.Id
    

    Now if you call

     Context.UpdateGraph(_person, m => m.OwnedCollection(x => x.Cars));  
    

This will add entities in collection from transient object missing in the persistent object and updates the object matching in the persistent object and deletes rest of the entities from the persistent object.

     var dbCars = conext.Where(x => x.Personid == _person.Id).Select(x).ToList();

say dbCars.Count is 8 and _person.Cars.Count is 3.(one new car and 2 old cars with updated values)
Once you run.

    Context.UpdateGraph(_person, m => m.OwnedCollection(x => x.Cars));

2 old cars from _person.Cars matching in dbCars will be updated
1 new car from _person.Cars not matching in dbCars will be added

Now the count of dbCars must be 9 as we added a new car. Now check the count.

  var dbCarCount = conext.Where(x => x.Personid == _person.Id).Select(x).ToList().Count();

dbCarCount will be 3. Rest of the 6 cars from dbCars are being removed.

I wish I am wrong as I like to use your solution.My work in this area is stalled. Please let me know If I'm missing something or you need more information. I know my write up is confusing as I tried to put all my testing experience with GraphDiff. Hope you address this issue.

Unable to cast object of type 'System.Linq.Expressions.MethodCallExpressionN' to type 'System.Linq.Expressions.MemberExpression'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Here's my graph:

Context.UpdateGraph(business, map => map
  .OwnedEntity(b => b.BusinessType)
  .AssociatedCollection(b => b.Categories)
  .OwnedCollection(b => b.Branches, branch => branch
    .AssociatedEntity(b => b.BranchType)
    .OwnedEntity(b => b.Address)
    .OwnedCollection(b => b.Phones)
    .OwnedCollection(b => b.CustomFields)
    .OwnedCollection(b => b.OpeningTimes, openingTimes => openingTimes
      .OwnedCollection(ot => ot.WorkingPeriods))));

Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Linq.Expressions.MethodCallExpressionN' to type 'System.Linq.Expressions.MemberExpression'.

Stack Trace:

[InvalidCastException: Unable to cast object of type 'System.Linq.Expressions.MethodCallExpressionN' to type 'System.Linq.Expressions.MemberExpression'.]
   GraphDiff.UpdateConfigurationVisitor`1.CreateIncludeExpression(UpdateMember previousMember, UpdateMember currentMember) +178
   GraphDiff.UpdateConfigurationVisitor`1.VisitMember(MemberExpression expression) +340
   System.Linq.Expressions.MemberExpression.Accept(ExpressionVisitor visitor) +12
   System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) +20
   System.Linq.Expressions.ExpressionVisitor.VisitLambda(Expression`1 node) +22
   System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor) +51
   System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) +20
   System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression node) +16
   System.Linq.Expressions.UnaryExpression.Accept(ExpressionVisitor visitor) +12
   System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) +20
   GraphDiff.UpdateConfigurationVisitor`1.VisitMethodCall(MethodCallExpression expression) +174
   System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor) +12
   System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) +20
   System.Linq.Expressions.ExpressionVisitor.VisitLambda(Expression`1 node) +22
   System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor) +51
   System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) +20
   System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression node) +16
   System.Linq.Expressions.UnaryExpression.Accept(ExpressionVisitor visitor) +12
   System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) +20
   GraphDiff.UpdateConfigurationVisitor`1.VisitMethodCall(MethodCallExpression expression) +174
   System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor) +12
   System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) +20
   System.Linq.Expressions.ExpressionVisitor.VisitLambda(Expression`1 node) +22
   System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor) +51
   System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) +20
   System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression node) +16
   System.Linq.Expressions.UnaryExpression.Accept(ExpressionVisitor visitor) +12
   System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) +20
   GraphDiff.UpdateConfigurationVisitor`1.VisitMethodCall(MethodCallExpression expression) +174
   System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor) +12
   System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) +20
   System.Linq.Expressions.ExpressionVisitor.VisitLambda(Expression`1 node) +22
   System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor) +51
   System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) +20
   GraphDiff.UpdateConfigurationVisitor`1.GetUpdateMembers(Expression`1 expression) +214
   GraphDiff.DbContextExtensions.UpdateGraph(DbContext context, T entity, Expression`1 mapping) +272
   Menahalim.Portal.Controllers.BusinessController.Save(Business business) in d:\Users\Shimmy\Documents\Visual Studio 2012\Projects\Menahalim\Portal\Controllers\BusinessController.cs:102
   Menahalim.Portal.Controllers.BusinessController.Edit(Business business) in d:\Users\Shimmy\Documents\Visual Studio 2012\Projects\Menahalim\Portal\Controllers\BusinessController.cs:91
   lambda_method(Closure , ControllerBase , Object[] ) +180
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +211
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.Async.<>c__DisplayClass42.b__41() +28
   System.Web.Mvc.Async.<>c__DisplayClass8`1.b__7(IAsyncResult _) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +48
   System.Web.Mvc.Async.<>c__DisplayClass39.b__33() +57
   System.Web.Mvc.Async.<>c__DisplayClass4f.b__49() +223
   System.Web.Mvc.Async.<>c__DisplayClass37.b__36(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +48
   System.Web.Mvc.Async.<>c__DisplayClass2a.b__20() +24
   System.Web.Mvc.Async.<>c__DisplayClass25.b__22(IAsyncResult asyncResult) +102
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
   System.Web.Mvc.<>c__DisplayClass1d.b__18(IAsyncResult asyncResult) +14
   System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
   System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.<>c__DisplayClass8.b__3(IAsyncResult asyncResult) +25
   System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629708
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Only seems to work with Ints.

For some reason this lib only seems to work with ints. If you take the unit tests mark all of the models as Guids every test fails. Even when all of the key properties are marked as [DatabaseGenerated(DatabaseGeneratedOption.Identity)].

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.