hat if the local data is modified and they try to load from database , the local cache will be overwritten
So is that behavior desirable in all applications and situations? Nope.
So how do you configure that behavior in code, and all possible variants? Like either keeping the modified data, dumping all the modified data, or just keeping some of it and replacing the rest, or replacing some of it based on rules, or dumping some of it based on rules, ... there's too many possibilities to list... And that's the exact reason why it doesn't show up in ORM's.
You're trying to get EF, and ORM's in general, to do something that is best left up to the coder. Hell, that's even what you said in your previous post!
By the way, your analogy doesn't even apply to this.
So how do you configure that behavior in code, and all possible variants? Like either keeping the modified data, dumping all the modified data, or just keeping some of it and replacing the rest, or replacing some of it based on rules, or dumping some of it based on rules, ... there's too many possibilities to list
no no , i'm telling that EF could have some rules , for example if you load data from database ( with a special command like reload ) the cached data will be overwritten. So a programmer can use this and i think it's easy to resolve the situations.EF has a Reload command but for a single object at time . If a have a list of entries that i want to reload , i should do one by one ??? why not all with a single command !!!!
By your opinion , better to have a full working Reload command and let programmers to resolve the possibilities . or to have something like my second solution where i'm fooling EF telling that those objects are detached in order to resolve my problem ????!!!
Then , really I don't understand why a such method does not exist on DBContext directly but I should use objectContext.
Because the option StoreWins means that the local cache will be overwritten with new data on my database , we have discussed this on our conversation.
You could import a text file directly to a datatable without storing it in a database.
However, the basic steps you need to perform:
1) Create a database table with columns defined to match the type of data that you want from the text file. Ex: Integer, date, Varchar, etc
2) create your VB program to loop through the text file parsing the data into the columns you want to store.
3) Execute a database INSERT statement to load the data on a line by line basis.
As you can see, this is a very vague solution. What area do you need help with?
Do you know how to create a database table? CREATE TABLE
Do you know know how to write a program to read a text file line by line?
Do you know how to parse a line into various fields?
Do you know how to execute an INSERT statement ?
Your question seems to be as vague as my proposed solution. Post a specific question so the group can answer it.
I'm trying to add a custom tooltip to my datagridview(s). In my research I know that the System.Windows.Forms.DataGridViewCellMouseEventArgs has no mouse hover event so instead I am using System.EventArgs. My problem of course that the mouse hover event only fires once on the datagridview until the user moves the mouse off the control. I need the event to fire each time the user hovers over a new row. Is there a way to reset the hover event on mouse move within the same control? I have searched and cannot find anything on this.
Here is my code which works perfectly but as mentioned only fires once.
Private Sub dtgNewMrs_cellMouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles dtgNewMRs0.MouseHover, dtgNewMRs1.MouseHover, dtgNewMRs2.MouseHover, dtgNewMRs3.MouseHover, dtgNewMRs4.MouseHover, dtgNewMRs5.MouseHover
Dim remMRNum As String
Dim remMRLin As String
Dim tTip As String = Nothing
Dim tCount As Integer = 1
Dim grvScreenLocation As Point = sender.PointToScreen(sender.Location)
Dim tempX As Integer = DataGridView.MousePosition.X - grvScreenLocation.X + sender.Left
Dim tempY As Integer = DataGridView.MousePosition.Y - grvScreenLocation.Y + sender.Top
Dim hit As DataGridView.HitTestInfo = sender.HitTest(tempX, tempY)
Dim chkRemarks As DataTable = rSet.Tables("RemarksMR")
remMRNum = .Rows(hit.RowIndex).Cells(3).Value
remMRLin = .Rows(hit.RowIndex).Cells(4).Value
Dim tQry = (From rems In chkRemarks.AsEnumerable()
Where rems.Field(Of String)("MR_Num") = remMRNum And
rems.Field(Of String)("MR_Line") = remMRLin).ToList()
Dim r = From t In tQry
If r.Count > 0 Then
For Each row As DataRow In r
tTip = tTip & Str(tCount) & ". " & row.Item(3) & Chr(13)
tCount += 1
We'll start with your assumption that the control will over ever be dropped on a Panel control. What if you accidentally drop it on a Form instead? You're code is going to throw an exception and the designer is going to show a problem that prevents rendering it and you'll probably freak out when that happens.
A control can have many different control types as a parent. Change the references "Panel" to "Control" so you can support different container controls, including a Form since the Form class derives from Control.
It's also not a good idea to rename your event handlers, specifically PChanged, to whatever is shorter. It make the code harder to read and understand without your eyes darting to the end of each line to figure out which event this method handles. Your name is also not descriptive at all. What's a "P" and what changes about it?
Sorry for not providing enough information. I was focused on the implementation
of whether Me._MyParentPanel = CType(sender,Control).Parent had any underlying issues
as far as 'attaching' the control to the Panels Scroll event because of loading
_MyParentPanel at runtime.
I understand and agree with the issues you raised but:
This control is for a specific application and will not be dropped onto the Panel or be
used for any other purpose.
It is created by a button click from the Panel and is added by the Panel onto the Panel.
I'm using entity framework 6 with sql server 2008r2.
I have a bindingsource :
Mybindingsource.datasource=(From t in context.myobjects order by t.name select t).ToList
Now , I want to search inside the bindingsource , and get the found item's index.
I'm using this code :
Function findindex(startposition as integer) As integer
Dim p as Myobject
Dim i as integer
For i=startposition to Mybindingsource.count-1
if p.value=3 then return i
This code is working , but when the bindingsource contains too many itmes , is very slow.