Search Results

Search found 6 results on 1 pages for 'levelbit'.

Page 1/1 | 1 

  • How to implement paging for datagrid using LINQ to Entities in wpf?

    - by Levelbit
    I'm new in wpf. My main problem is to understand how DataGrid works with its datacontext. It would help me a lot because I don't know how to make a universal paging usercontrol for all my datagrids in the projects for different database tables. DataGrid converts received DataContext from object to some kind of list. How it is implemented. I tried to do some casting from object to IQueryable to generalize thinig because base class of every entity in the entity model is EntityObject class. But it doesen't work in runtime although I don't receive complains at design time.

    Read the article

  • Problem creating ObjectContext from different project inside solution.

    - by Levelbit
    I have two projects in my Solution. One implements my business logic and has defined entity model of entity framework. When I want to work with classes defined within this project from another project I have some problems in runtime. Actually, the most concerning thing is why I can not instantiate my, so called, TicketEntities(ObjectContext) object from other projects? when I catch following exception: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. I found out it's brake at: public partial class TicketEntities : global::System.Data.Objects.ObjectContext { public TicketEntities() : base("name=TicketEntities", "TicketEntities") { this.OnContextCreated(); } with exception: Unable to load the specified metadata resource. Just to remind you everthing works fine from orginal project.

    Read the article

  • Help with editing data in entity framework.

    - by Levelbit
    Title of this question is simple because there is no an easy explanation for what I'm trying to ask you. I hope you'll understand in the end :). I have to tables in my database: Company and Location (relationship:one to many) and corresponding entity sets. In my wpf application I have some datagrid which I want to fill with locations and to be able to edit every row in separate window as some form of details view (so I don't want to edit my data in datagrid). I did this by accessing Location entity from selected row and creating a new Location entity and then I copy properties from original entity to newly created. Something like cloning the object. After editing if I press OK changed data is copied to original object back, and if I press Cancel nothing happens. Of course, you probably thinking I could use NoTracking option and AttachAsModified method as was mentioned as solution in some earlier questions(see:http://stackoverflow.com/questions/803022/changing-entities-in-the-entityframework) by Alex James, but lets say I had some problems about that and I have my own reasons for doing this. Finally, because navigation property(Company) of my location entity is assigned to newly created location object(during cloning) from some reason in object context additional object as copy of object I want to edit from datagrid is created without my will(similar problem :http://blogs.msdn.com/alexj/archive/2009/12/02/tip-47-how-fix-up-can-make-it-hard-to-change-relationships.aspx). So, when I do ObjectContext.SaveChanges it inserts additional row of data into my database table Location, the same as the one i wanted to edit. I read about sth like this, but I don't quite understand why is that and how to block or override this. I hope I was clear as I could. Please, solutions or some other ideas.

    Read the article

  • How to add entity object to adequate entity set with object context in EF?

    - by Levelbit
    I have a problem when I add an entity object with ObjectContext.AddObject method because I can't retrieve that object with LINQ querying my ObjectContext.Person entities. I know that this new added object is stored somewhere, because it is used to update database after SaveChanges method. That's bothers me because I want to update my datagrid DataContext without saving changes unless I really want to do it. It doesn't help if I add the same object to DataContext list myself directly.

    Read the article

  • How to ask database server for current datetime using entity framework?

    - by Levelbit
    I don't want for my current ModifeidDateTime to be machine time already server time. Every time I want to update or add a person to my datebase on SQL Server 2008 I want to fill ModifiedDateTime filed. It's not like I can change update query as with data adapter command when I work with dataset and to define for my ModifiedDateTime filed to be =GetDate(). I created stored function to retutn me a value of GetDate() method, but I have a problem to import procedure which returns values as int, string ... or no value at all, already just entity values as Person for example in my case. Why is that? Anyway, It would be of great help if you can provide me any solution that works to retrieve DateTime value from server.

    Read the article

  • Why newly created entity object with navigation property is automaticly added to ObjectContext?

    - by Levelbit
    I have to entities: Company and Location (one to many). When I create new Location entity object and assign navigation property(Company) with the navigation property of already existing Location object (Location _new = new Location(); _new.Company = _old.Company). It seems that at that point newly created object is added to Object Context automatically, because when I call SaveChanges method that object is insert to database although I didn't call ObjectContext.AddObject(_new). I'm new in EF so there is probably reason why I have result like this? Is there need to assign also CompanyReference filed too and how to do it? IDaoFactory daoFactory = new DaoFactory(); ILocationDao locaitonDao = daoFactory.GetLocationDao(); IEnumerable<Location> locations = locaitonDao.GetLocations(); Location _old = locations.First(); Location _new = new Location(); _new.LocationName = _old.LocationName; _new.Company = _old.Company;// 1 _new.Address = _old.Address; //... ContactEntities.SaveChanges();//2 If I execute line (1) instantly _new object is added to object context and I can see additional datarow in my datagrid after line (2) is executed.

    Read the article

1