Search Results

Search found 9916 results on 397 pages for 'entity component'.

Page 107/397 | < Previous Page | 103 104 105 106 107 108 109 110 111 112 113 114  | Next Page >

  • EF Code First - Relationships

    - by CaffGeek
    I have these classes public class EntityBase : IEntity { public int Id { get; set; } public DateTime Created { get; set; } public string CreatedBy { get; set; } public DateTime Updated { get; set; } public string UpdatedBy { get; set; } } public class EftInterface : EntityBase { public string Name { get; set; } public Provider Provider { get; set; } public List<BusinessUnit> BusinessUnits { get; set; } } public class Provider : EntityBase, IEntity { public string Name { get; set; } public decimal DefaultDebitLimit { get; set; } public decimal DefaultCreditLimit { get; set; } public decimal TreasuryDebitLimit { get; set; } public decimal TreasuryCreditLimit { get; set; } } public class BusinessUnit : EntityBase { public string Name { get; set; } } An interface, is really a Provider, with a collection of Business Units. The issue is that while my db model ends up having a correct EftInterfaces table, with a FK to Provider_Id, the BusinessUnits table has a FK to EftInterface_Id. But, a BusinessUnit can be included in more than one EftInterface. I need a many to many relationship. A BusinessUnit can be part of many EftInterfaces, and an EftInterface can contain many BusinessUnits. How can I get CodeFirst to generate the many-to-many table?

    Read the article

  • Open Source - EER Modeling Tool

    - by Nick Fergis
    Is there a good open source or reasonably priced EER modeling tool for MySQL besides MySQL Workbench? I find the MySQL Workbench interface to be clunky. I would like to be able to manage my production schema beginning all design changes in the EER and propogating those out to my schema for created and altered tables. Is anyone use a tool they love to manage their environments in this way? Thanks. - Nick

    Read the article

  • How to write simple Where Clause for dynamic filtering in linq when we use groups in join

    - by malik
    I have simple search page i want to filter the results. var TransactionStats = from trans in context.ProductTransactionSet.Include("SPL") select new { trans.InvoiceNo, ProductGroup = from tranline in trans.ProductTransactionLines group tranline by tranline.ProductTransaction.TransactionID into ProductGroupDetil select new { TransactionDateTime = ProductGroupDetil.Select (Content => Content.TransactionDateTime) } }; I want to use TransactionDateTime in where clause when required. if (_FilterCrieteria.DateFrom.HasValue) { TransactionStats.Where ( a => a.ProductGroup.Where ( dt => dt.DateofTransaction >= _FilterCrieteria.DateFrom && dt.DateofTransaction >= _FilterCrieteria.DateFrom ) ) } Can any one correct the syntax?

    Read the article

  • How to pass a Lambda Expression as method parameter with EF

    - by Registered User
    How do I pass an EF expression as a method argument? To illustrate my question I have created a pseudo code example: The first example is my method today. The example utilizes EF and a Fancy Retry Logic. What I need to do is to encapsulate the Fancy Retry Logic so that it becomes more generic and does not duplicate. In the second example is how I want it to be, with a helper method that accepts the EF expression as an argument. This would be a trivial thing to do with SQL, but I want to do it with EF so that I can benefit from the strongly typed objects. First Example: public static User GetUser(String userEmail) { using (MyEntities dataModel = new MyEntities ()) { var query = FancyRetryLogic(() => { (dataModel.Users.FirstOrDefault<User>(x => x.UserEmail == userEmail))); }); return query; } } Second Example: T RetryHelper<T>(Expression<Func<T, TValue>> expression) { using (MyEntities dataModel = new (MyEntities ()) { var query = FancyRetryLogic(() => { return dataModel.expression }); } } public User GetUser(String userEmail) { return RetryHelper<User>(<User>.FirstOrDefault<User>(x => x.UserEmail == userEmail)) }

    Read the article

  • em.createQuery keeps returning null

    - by Developer106
    I have this application which i use JSF 2.0 and EclipseLink, i have entities created for a database made in MySQL, Created these entities using netbeans 7.1.2, it gets created automaticly. Then i use session beans to work with these entities, the thing is the em.createQuery always returns a null, though I checked NamedQueries in the entities and they perfectly match a sample from the entities named queries:- @NamedQueries({ @NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"), @NamedQuery(name = "Users.findByUserId", query = "SELECT u FROM Users u WHERE u.userId = :userId"), @NamedQuery(name = "Users.findByUsername", query = "SELECT u FROM Users u WHERE u.username = :username"), @NamedQuery(name = "Users.findByEmail", query = "SELECT u FROM Users u WHERE u.email = :email"), notice how i use this findByEmail query in the session bean :- public Users findByEmail(String email){ em.getTransaction().begin(); String find = "Users.findByEmail"; Query query = em.createNamedQuery(find); query.setParameter("email", email); Users user = (Users) query.getSingleResult(); but it always returns null from this em.createNamedQuery, i tried using .createQuery first but it also was no good. the stacktrace of the exception Caused by: java.lang.NullPointerException at com.readme.entities.sessionBeans.UsersFacade.findByEmail(UsersFacade.java:48) at com.readme.user.signup.SignupBean.checkAvailability(SignupBean.java:137) at com.readme.user.signup.SignupBean.save(SignupBean.java:146) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) What Seems To Be The Problem Here ?

    Read the article

  • Using CreateSourceQuery in CTP4 Code First

    - by Adam Rackis
    I'm guessing this is impossible, but I'll throw it out there anyway. Is it possible to use CreateSourceQuery when programming with the EF4 CodeFirst API, in CTP4? I'd like to eagerly load properties attached to a collection of properties, like this: var sourceQuery = this.CurrentInvoice.PropertyInvoices.CreateSourceQuery(); sourceQuery.Include("Property").ToList(); But of course CreateSourceQuery is defined on EntityCollection<T>, whereas CodeFirst uses plain old ICollection (obviously). Is there some way to convert? I've gotten the below to work, but it's not quite what I'm looking for. Anyone know how to go from what's below to what's above (code below is from a class that inherits DbContext)? ObjectSet<Person> OSPeople = base.ObjectContext.CreateObjectSet<Person>(); OSPeople.Include(Pinner => Pinner.Books).ToList(); Thanks! EDIT: here's my version of the solution posted by zeeshanhirani - who's book by the way is amazing! dynamic result; if (invoice.PropertyInvoices is EntityCollection<PropertyInvoice>) result = (invoices.PropertyInvoices as EntityCollection<PropertyInvoice>).CreateSourceQuery().Yadda.Yadda.Yadda else //must be a unit test! result = invoices.PropertyInvoices; return result.ToList(); EDIT2: Ok, I just realized that you can't dispatch extension methods whilst using dynamic. So I guess we're not quite as dynamic as Ruby, but the example above is easily modifiable to comport with this restriction EDIT3: As mentioned in zeeshanhirani's blog post, this only works if (and only if) you have change-enabled proxies, which will get created if all of your properties are declared virtual. Here's another version of what the method might look like to use CreateSourceQuery with POCOs public class Person { public virtual int ID { get; set; } public virtual string FName { get; set; } public virtual string LName { get; set; } public virtual double Weight { get; set; } public virtual ICollection<Book> Books { get; set; } } public class Book { public virtual int ID { get; set; } public virtual string Title { get; set; } public virtual int Pages { get; set; } public virtual int OwnerID { get; set; } public virtual ICollection<Genre> Genres { get; set; } public virtual Person Owner { get; set; } } public class Genre { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual Genre ParentGenre { get; set; } public virtual ICollection<Book> Books { get; set; } } public class BookContext : DbContext { public void PrimeBooksCollectionToIncludeGenres(Person P) { if (P.Books is EntityCollection<Book>) (P.Books as EntityCollection<Book>).CreateSourceQuery().Include(b => b.Genres).ToList(); }

    Read the article

  • MVC DropDownListFor not populating the selected value

    - by user2254436
    I'm really having troubles with MVC, in another project I've done the same thing and it worked fine but in this project I just don't understand why the selected item in the dropdown is not populating the class correctly with EF. I have 2 classes: public partial class License { public License() { this.Customers = new HashSet<Customer>(); } public int LicenseID { get; set; } public int Lic_LicenseTypeID { get; set; } public int Lic_LicenseStatusID { get; set; } public string Lic_LicenseComments { get; set; } public virtual EntitiesList LicenseStatus { get; set; } public virtual EntitiesList LicenseType { get; set; } } public partial class EntitiesList { public EntitiesList() { this.LicensesStatus = new HashSet<License>(); this.LicensesType = new HashSet<License>(); } public int ListID { get; set; } public string List_EntityValue { get; set; } public string List_Comments { get; set; } public string List_EntityName { get; set; } public virtual ICollection<License> LicensesStatus { get; set; } public virtual ICollection<License> LicensesType { get; set; } public string List_DisplayName { get { return Regex.Replace(List_EntityName, "([a-z])([A-Z])", "$1 $2"); ; } } public string List_DisplayValue { get { return Regex.Replace(List_EntityValue, "([a-z])([A-Z])", "$1 $2"); } } } The EntitiesList is table in db that have all my "enum" lists. For example: ListID - 0 List_EntityValue - Activate List_EntityName - LicenseStatus ListID - 1 List_EntityValue - Basic List_EntityName - LicenseType This is my model: public class LicenseModel { public License License { get; set; } public SelectList LicenseStatuses { get; set; } public int SelectedStatus { get; set; } public SelectList LicenseTypes { get; set; } public int SelectedType { get; set; } } My controller for create: public ActionResult Create() { LicenseModel model = new LicenseModel(); model.License = new License(); model.LicenseStatuses = new SelectList(managerLists.GetAllLicenseStatuses(), "ListID", "List_DisplayValue"); model.LicenseTypes = new SelectList(managerLists.GetAllLicenseTypes(), "ListID", "List_DisplayValue"); return View(model); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(LicenseModel model) { if (ModelState.IsValid) { model.License.Lic_LicenseTypeID = model.SelectedType; model.License.Lic_LicenseStatusID = model.SelectedStatus; managerLicense.AddNewObject(model.License); return RedirectToAction("Index"); } return View(model); } managerLists and managerLicense are the managers that connect between the entities in db and the MVC UI, nothing special... they contains queries for adding new objects, getting the lists, editing and so on. And the view for creating the License: @using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) <fieldset> <legend>License</legend> <div class="form-group"> @Html.LabelFor(model => model.License.Lic_LicenseTypeID) @Html.DropDownListFor(model => model.SelectedType, Model.LicenseTypes, new { @class = "form-control" }) <p class="help-block">@Html.ValidationMessageFor(model => model.License.Lic_LicenseTypeID)</p> </div> <div class="form-group"> @Html.LabelFor(model => model.License.Lic_LicenseStatusID) @Html.DropDownListFor(model => model.SelectedStatus, Model.LicenseStatuses, new { @class = "form-control" }) <p class="help-block">@Html.ValidationMessageFor(model => model.License.Lic_LicenseStatusID)</p> </div> <div class="form-group"> @Html.LabelFor(model => model.License.Lic_LicenseComments) @Html.TextAreaFor(model => model.License.Lic_LicenseComments, new { @class = "form-control", rows = "3" }) <p class="help-block">@Html.ValidationMessageFor(model => model.License.Lic_LicenseComments)</p> </div> <p> <input type="submit" value="Create" /> </p> </fieldset> } Now, when I'm trying to save the new license, when it gets to the db.SaveChanges() in the manager I'm getting: "Validation failed for one or more entities. See 'EntityValidationErrors' property for more details." In breakpoint, the Lic_LicenseTypeID and Lic_LicenseStatusID are getting correctly the ID's from the selected item in the dropdown but the LicenseStatus and LicenseStatus properties are null. What an I missing?

    Read the article

  • Cannot perform an ORDERBY against my EF4 data

    - by Jaxidian
    I have a query hitting EF4 using STEs and I'm having an issue with user-defined sorting. In debugging this, I have removed the dynamic sorting and am hard-coding it and I still have the issue. If I swap/uncomment the var results = xxx lines in GetMyBusinesses(), my results are not sorted any differently - they are always sorting it ascendingly. FYI, Name is a varchar(200) field in SQL 2008 on my Business table. private IQueryable<Business> GetMyBusinesses(MyDBContext CurrentContext) { var myBusinesses = from a in CurrentContext.A join f in CurrentContext.F on a.FID equals f.id join b in CurrentContext.Businesses on f.BID equals b.id where a.PersonID == 52 select b; var results = from r in myBusinesses orderby "Name" ascending select r; //var results = from r in results // orderby "Name" descending // select r; return results; } private PartialEntitiesList<Business> DoStuff() { var myBusinesses = GetMyBusinesses(); var myBusinessesCount = GetMyBusinesses().Count(); Results = new PartialEntitiesList<Business>(myBusinesses.Skip((PageNumber - 1)*PageSize).Take(PageSize).ToList()) {UnpartialTotalCount = myBusinessesCount}; return Results; } public class PartialEntitiesList<T> : List<T> { public PartialEntitiesList() { } public PartialEntitiesList(int capacity) : base(capacity) { } public PartialEntitiesList(IEnumerable<T> collection) : base(collection) { } public int UnpartialTotalCount { get; set; } }

    Read the article

  • DataServiceCollection load from external source

    - by spdro
    I'm trying to load external data to my entyity. DataServiceCollection<products> products = new DataServiceCollection<products>(); var adapter = new OleDbDataAdapter("SELECT * FROM [products$]", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=d:\\products.xlsx;Extended Properties=\"Excel 12.0;HDR=YES;\""); DataSet ds = new DataSet(); adapter.Fill(ds, "excell"); products.Load(????); Can anyone help ?

    Read the article

  • MVC 1.0 + EF: Does db.EntitySet.where(something) still return all rows in table?

    - by Dale
    In a repository, I do this: public AgenciesDonor FindPrimary(Guid donorId) { return db.AgenciesDonorSet.Include("DonorPanels").Include("PriceAdjustments").Include("Donors").First(x => x.Donors.DonorId == donorId && x.IsPrimary); } then down in another method in the same repository, this: AgenciesDonor oldPrimary = this.FindPrimary(donorId); In the debugger, the resultsview shows all records in that table, but: oldPrimary.Count(); is 1 (which it should be). Why am I seeing all table entries retrieved, and not just 1? I thought row filtering was done in the DB. If db.EntitySet really does fetch everything to the client, what's the right way to keep the client data-lite using EF? Fetching all rows won't scale for what I'm doing.

    Read the article

  • Pivot to obtain EAV data

    - by Snowy
    I have an EAV table (simple key/value in every row) and I need to take the 'value' from two of the rows and concat them into a single row with a single column. I can't seem to get through the part where I just have the pivot straight. Can anyone help me figure this out? Declare @eavHelp Table ( [Key] VARCHAR (8) NOT NULL, [Value] VARCHAR (8) NULL ) Insert Into @eavHelp Values ( 'key1' , 'aaa' ) Insert Into @eavHelp Values ( 'key2' , 'bbb' ) Select * From @eavHelp Pivot ( Min( [Value] ) For [Value] in ( hmm1 , hmm2 ) ) as Piv Where [Key] = 'key1' or [Key] = 'key2' That makes: Key hmm1 hmm2 -------- -------- -------- key1 NULL NULL key2 NULL NULL But what I want to make is: hmmmX ----- aaa;bbb

    Read the article

  • Creating seed model from data already in DB

    - by Nick Brown
    Is there a way to convert data in an existing database into objects that can easily be put into a seed method? Essentially I'd like to let some people add lines to my DB via a form and then convert that into an object that I can re-seed the DB anytime I need to make changes. The database itself is created via code-first using the following model: public class Combo { public int Id { get; set; } public string MainPrefix { get; set; } public string MainDescriptor { get; set; } public string MainDish { get; set; } public string Connector { get; set; } public string SecondaryDescriptor { get; set; } public string SecondaryDish { get; set; } }

    Read the article

  • Are there any pitfalls to having two different Models from two different assemblies? (EF)

    - by Jonn
    I have two projects, both of them data access layers, and both using EF. I have another project calling services related to the two different assemblies. Are there any pitfalls on using two different models on two different databases linked to the same database? I'm asking this because I've been getting this generic "EntitySqlException" could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly., near escaped identifier. that does not appear when are run separately but appear when under the same project.

    Read the article

  • Linq2SQL or EntityFramework and databinding

    - by rene marxis
    is there some way to do databinding with linq2SQL or EntityFramework using "typed links" to the bound property? Public Class Form1 Dim db As New MESDBEntities 'datacontext/ObjectContext Dim bs As New BindingSource Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load bs.DataSource = (From m In db.PROB_GROUP Select m) grid.DataSource = bs TextBox1.DataBindings.Add("Text", bs, "PGR_NAME") TextBox1.DataBindings.Add("Text", bs, db.PROB_GROUP) '**<--- Somthing like this** End Sub End Class I'd like to have type checking when compiling and the model changed.

    Read the article

  • List<T> paging asp.net

    - by user1397978
    Using a three-tier architecture, I have a list of objects List<object> careerList = new List<object>(); ModuleDTO module = new ModuleDTO(); careerList = module.getDegreeCodeByQualification(qualificationCode); which I then add to a gridview like so: gridViewMaster.DataSource = careerList; gridViewMaster.DataBind(); What I'd like to do is then enable paging on the gridview. My gridview so far is: <asp:GridView ID="gridViewMaster" runat="server" AutoGenerateColumns="False" GridLines="None" BorderWidth="1px" CellPadding="2" DataKeyNames="Grouping" ForeColor="Black" onrowdatabound="gridViewMaster_RowDataBound" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" OnPageIndexChanging="gridView_PageIndexChanging" AllowPaging="True" > Is it possible to do enable paging on a list's without having to change that list to a Datatable or Dataview? If there is a way, this would help a lot. So far my events are as follows: protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { gridViewMaster.PageIndex = e.NewPageIndex; List<object> careerList = new List<object>(); ModuleDTO module = new ModuleDTO(); careerList = module.getDegreeCodeByQualification(qualificationCode); ModalProgress.Show(); System.Threading.Thread.Sleep(1000); JobPanel.Visible = true; gridViewMaster.DataSource = careerList.Distinct(); gridViewMaster.DataBind(); } Someone PLEASE HELP ME!!! Thank you

    Read the article

  • Convert this SQL Query into LINQ (OVER (PARTITION BY Date))

    - by user1106649
    Here's the query i'm trying to convert into Linq: SELECT R.Code, R.FlightNumber, S.[Date], S.Station, R.Liters, SUM(R.Liters) OVER (PARTITION BY Year([Date]), Month([Date]), Day([Date])) AS Total_Liters FROM S INNER JOIN R ON S.ID = R.SID WHERE (R.Code = 'AC') AND FlightNumber = '124' GROUP BY Station, Code, FlightNumber, [Date], Liter ORDER BY R.FlightNumber, [Date] Thanks for any help.

    Read the article

  • Linq Having Sum(Quantity) = x?

    - by molgan
    Hello I have a function that returns IQueryable, and I would like to add "HAVING SUM(Quantity) = X" to it, but I get error if I try like this: _rep.GetBookings().ByBookingObjectID(bookingObjectID).Sum(x => x.Quantity == somevariablehere); I cant seem to find functions for it to find by sum /M

    Read the article

  • WCF operationcontract with List type unavailable in (Silverlight) client

    - by Dave
    This is the first time I have tried returning a List of data to a Silverlight client, so I'm having trouble getting the client to recognize this operationcontract. All others are fine. I have a method on the server called ReadOwFileData that needs to return a List. ReadOwFileDataCompletedEventArgs shows up in the Object Browser in the client, but not ReadOwFileDataAsync. What I want is similar to the tutorial here. The Dictionary collection type on the client is set to System.Collections.Generic.List. I tried deleting and recreating the service reference. Web.Config on the server is using basicHttpBinding. Here is the operationcontract on the server: [OperationContract] public List<OwFileData> ReadOwFileData(string OrderID) { DataClasses1DataContext db = new DataClasses1DataContext(); var dFileData = (from p in db.OwFileDatas where p.OrderID == OrderID select p).ToList(); List<OwFileData> x = new List<OwFileData>(dFileData); return x; } Incidently, this works fine: [OperationContract] public Customer GetShippingAndContactInfo(string login, string ordernum) { DataClasses1DataContext db = new DataClasses1DataContext(); Customer dInfo = (from p in db.Customers where p.Login == login select p).Single(); return dInfo; } I would like to read this data in the client and place it into an object I created called ObservableCollection. But that obviously can't happen until the client can see the method on the server. I do not know if this is an acceptable start, but this is what is on the client so far. The ReadOwFileDataAsync object is null: void populatefilesReceivedDataSource(string OrderID) { ArtUpload.ServiceReference1.UploadServiceClient client = new ArtUpload.ServiceReference1.UploadServiceClient(); var myList = client.ReadOwFileDataAsync(OrderID); // can I just itterate thru the list instead of 'binding' }

    Read the article

  • Linq to Entities strange deploying behavior.

    - by SO give me back my rep
    Hi I started building apps with this technology and I am facing a weird problem... on some machines I need to add theese lines to the app.config to get to work: <system.data> <DbProviderFactories> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> </DbProviderFactories> </system.data> while in other machines it runs well without theese lines.... the thing is that when I add theese lines the app wont run on machines that did not needed theese lines in the firs place, and I would like not to publish to versions of the app, is there a way to solve this?

    Read the article

  • does this raw sql only one trip to the database or many trips?

    - by Álvaro García
    I gues that I have this sql: string strTSQL = "Begin TRAN delete from MyTable where ID = 1"; string strTSQL = ";delete from MyTable where ID = 2"; string strTSQL = ";delete from MyTable where ID = 3 COMMIT"; using(Entities dbContext = new Entities()) { dbCntext.MyTable.SQLQuery(strTSQL); } This use a transaction in the dataBase, so all the commands are executed or no one. But how I execute it through EF, it does only one trip to the database or many? Thanks.

    Read the article

  • How do I deal with connection strings in a Click-Once application?

    - by Pwninstein
    I'm thinking of building a Click-Once application, and am trying to wrap my head around how to handle the whole connection string issue. The problem is the following: I want to use EF to get data directly from each client, thus requiring each client to have a connection string configured (this is not the issue). How do I deal with clients that are not on the same domain as the SQL Server being queried? In other words, if I tried to run my app from home as opposed to from work, what should my connection string look like? Would I need to configure my SQL Server differently to allow this scenario? Thanks in advance!

    Read the article

  • Linq-to-Entities Dynamic sorting

    - by verror
    This is my query, how can I use string as orderby parameter? string sortColumn="Title"; var items = (from ltem in ctxModel.Items where ltem.ItemID == vId orderby //something here select ltem).Skip(PageSize * PageIndex).Take(PageSize);

    Read the article

  • Linq to Entities (EF): How to get the value of a FK without doing the join

    - by Chu
    I'm using the Linq to Entities. I've got my main table, Employee setup with a field named vendorID. Vendor ID is a foreign key into the Vendors table. As it is right now, the Employee object does not directly expose the vendorID. Instead, I can only access it this way: var employee = (from e in context.Employees.Include("tbl_vendors") where e.employeeID = 1 select e).FirstOrDefault(); //this gets the vendor ID int vendorID = employee.tbl_vendors.vendorID; That is just fine and dandy, but it is extra work on the database because it is forcing a join where none is needed. Is there a way to get that key value without being forced to do a join to the tbl_vendors table?

    Read the article

< Previous Page | 103 104 105 106 107 108 109 110 111 112 113 114  | Next Page >