First to Insert just
Create New object of your mapping
ex: class MyuserList
string username;
int age;
MyuserList a=new MyuserList();
a.username="cipto";
a.age="26";
or Dynamicinsert(a);
Mydatacontext tmp=new Mydatacontext();
tmp.insertonsubmit(a);
For Update
-------------------
just get the recod and change the properti and then
submitchanges();=>everything is update to DB
Kamis, 24 Januari 2008
LinQ Example
How To Get End result as List
-------------------------------
public IList GetAllEntity()
{
var r = (from s in Manager.Context.CalculationFormula select s.Code).ToList();
return r;
}
How to Get just One Row Result
----------------------------------
public CalculationFormula GetbyCode(string code)
{
var r = (from s in Manager.Context.CalculationFormula
where s.Code==code
select s).Single();
return r;
}
How to Order the Result
-----------------------
return Entity.GetByJobiD(ID).OrderBy(s=>s.RowIndex).ToList();
How to Lazy loading
----------------------
I assume the meaning is, because on each object we have one to many relation ship you can told linq to hold/postpone the loading of these related data by setting it's differedloading=false;
How to get datatable
----------------------
unfortunately you have to have your datatable as source first, there's no way of returning as datatable, so from datatable source you can Query it again againts it. and return as a new datatalbe result using linq.datasetextension.dll the method name is , .CopyasDatatable() or .CopyasDataView()
HOw to join to several tables, join, etc,
-----------------------------------------
Now linq can get very complex, and hierrachiall(does this spell right?)
but it's your job to find out.
-------------------------------
public IList
{
var r = (from s in Manager.Context.CalculationFormula select s.Code).ToList();
return r;
}
How to Get just One Row Result
----------------------------------
public CalculationFormula GetbyCode(string code)
{
var r = (from s in Manager.Context.CalculationFormula
where s.Code==code
select s).Single();
return r;
}
How to Order the Result
-----------------------
return Entity.GetByJobiD(ID).OrderBy(s=>s.RowIndex).ToList();
How to Lazy loading
----------------------
I assume the meaning is, because on each object we have one to many relation ship you can told linq to hold/postpone the loading of these related data by setting it's differedloading=false;
How to get datatable
----------------------
unfortunately you have to have your datatable as source first, there's no way of returning as datatable, so from datatable source you can Query it again againts it. and return as a new datatalbe result using linq.datasetextension.dll the method name is , .CopyasDatatable() or .CopyasDataView()
HOw to join to several tables, join, etc,
-----------------------------------------
Now linq can get very complex, and hierrachiall(does this spell right?)
but it's your job to find out.
Infragistic UltraGrid
how to Hide Column
-------------------
private void ultraGrid1_InitializeLayout{
foreach (UltraGridColumn oColumn in (sender as UltraGrid ) .DisplayLayout.Bands[0].Columns)
{
switch (oColumn.Key.ToUpper())
{
case "ISFORMULA":
oColumn.Hidden = true;
break;
case "ISTITLE":
oColumn.Hidden = true;
break;
case "ISITEM":
oColumn.Hidden = true;
break;
case "ISSUBTOTAL":
oColumn.Hidden = true;
break;
}
}
}
Setting cell Value
--------------------
ultraGrid1.ActiveRow.Cells[0].SetValue("",false);
How to Focus on a Cell
-------------------------
ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
to exit the edit mode
ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false, false);
Coloring Rows/Cell
-------------------
ultraGrid1.DisplayLayout.Rows[rowindex].CellAppearance.BackColor = Color.Gray;
Cell.Appearance.BackColor = Color.Red;
How to on Enter move to next Cell that has Focus(Text)
-------------------
void NextControlFocus()
{
int index=ultraGrid1.ActiveCell.Column.Index;
ultraGrid1.ActiveRow.Cells[index+1].Activate();
ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
}
How to Get the Object that Bind to The grid current Row
-------------------------------------------------------
1.((object)BindingContext[ultraGrid1.DataSource].Current); Or
2.ultraGrid1.ActiveRow.ListObject
How to for a Cell to be a multiline Text and have scrollbar and always prompt when edit mode?
--------------------------------------------------------
On Initialize Layout
ultraGrid1.DisplayLayout.Bands[0].Columns["Description"].CellMultiLine = DefaultableBoolean.True;
ultraGrid1.DisplayLayout.Bands[0].Columns["Description"].VertScrollBar = true;
e.Layout.ScrollStyle = ScrollStyle.Immediate;
How to Process Data from ClipBoard or Ctrl+C
--------------------------------------------
on Key Down.
switch (e.KeyData)
{
case Keys.Control|Keys.V:
this.ProcessData();
On ProcessData
DataObject o = Clipboard.GetDataObject() as DataObject;
if (!o.GetDataPresent("Text")) return; //Make sure we have Clipboard text
string theClipboardText = (string)o.GetData("Text", true);
How to Resize?
---------------
1.ultraGrid1.Rows.Band.Columns[1].PerformAutoResize();
2.AutoFitStyle
How to Validate Each Cell in row before leaving?
-------------------------------------------------
OnLast Cell key press refer to
private bool ValidateAllCellinRow()
{
CellsCollection allcell = ultraGrid1.ActiveRow.Cells;
foreach (UltraGridCell tmp in allcell)
{
if (tmp.Text == "" )
{
MessageBox.Show(tmp.Column.Key + " May not be empty");
ultraGrid1.ActiveRow.Cells[tmp.Column.Key].Activate();
ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
return false;
}
}
return true;
}
how to delete silently
--------------------------
ultraGrid1.ActiveRow.Delete(false);
-------------------
private void ultraGrid1_InitializeLayout{
foreach (UltraGridColumn oColumn in (sender as UltraGrid ) .DisplayLayout.Bands[0].Columns)
{
switch (oColumn.Key.ToUpper())
{
case "ISFORMULA":
oColumn.Hidden = true;
break;
case "ISTITLE":
oColumn.Hidden = true;
break;
case "ISITEM":
oColumn.Hidden = true;
break;
case "ISSUBTOTAL":
oColumn.Hidden = true;
break;
}
}
}
Setting cell Value
--------------------
ultraGrid1.ActiveRow.Cells[0].SetValue("",false);
How to Focus on a Cell
-------------------------
ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
to exit the edit mode
ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false, false);
Coloring Rows/Cell
-------------------
ultraGrid1.DisplayLayout.Rows[rowindex].CellAppearance.BackColor = Color.Gray;
Cell.Appearance.BackColor = Color.Red;
How to on Enter move to next Cell that has Focus(Text)
-------------------
void NextControlFocus()
{
int index=ultraGrid1.ActiveCell.Column.Index;
ultraGrid1.ActiveRow.Cells[index+1].Activate();
ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
}
How to Get the Object that Bind to The grid current Row
-------------------------------------------------------
1.((object)BindingContext[ultraGrid1.DataSource].Current); Or
2.ultraGrid1.ActiveRow.ListObject
How to for a Cell to be a multiline Text and have scrollbar and always prompt when edit mode?
--------------------------------------------------------
On Initialize Layout
ultraGrid1.DisplayLayout.Bands[0].Columns["Description"].CellMultiLine = DefaultableBoolean.True;
ultraGrid1.DisplayLayout.Bands[0].Columns["Description"].VertScrollBar = true;
e.Layout.ScrollStyle = ScrollStyle.Immediate;
How to Process Data from ClipBoard or Ctrl+C
--------------------------------------------
on Key Down.
switch (e.KeyData)
{
case Keys.Control|Keys.V:
this.ProcessData();
On ProcessData
DataObject o = Clipboard.GetDataObject() as DataObject;
if (!o.GetDataPresent("Text")) return; //Make sure we have Clipboard text
string theClipboardText = (string)o.GetData("Text", true);
How to Resize?
---------------
1.ultraGrid1.Rows.Band.Columns[1].PerformAutoResize();
2.AutoFitStyle
How to Validate Each Cell in row before leaving?
-------------------------------------------------
OnLast Cell key press refer to
private bool ValidateAllCellinRow()
{
CellsCollection allcell = ultraGrid1.ActiveRow.Cells;
foreach (UltraGridCell tmp in allcell)
{
if (tmp.Text == "" )
{
MessageBox.Show(tmp.Column.Key + " May not be empty");
ultraGrid1.ActiveRow.Cells[tmp.Column.Key].Activate();
ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
return false;
}
}
return true;
}
how to delete silently
--------------------------
ultraGrid1.ActiveRow.Delete(false);
Linq to SQL
well it's my first post on linq to SQL.
after several days using it.
Hmmm
i found it quite intersesting
By default
it generate's everything(table,storeproc) that u click drag to the dbml
including store procedure(will be come a method in our vs)..
Hmmm.. i'm trying to bind ienumerable to infragistic grid, and it's a mess...
some table display valid some hang out. guess the datatable is the solution for binding or Customized through ultra data source
u can combine with extension or, just add your additional method to your object.
by default linq is optimistic concurrency.
meaning that if on multi user environment,when a user trying to update or delete a row which has been changed by other user it throws exception.
Using transaction in linq to sql :
http://blogs.msdn.com/wriju/archive/2007/08/06/linq-to-sql-using-transaction.aspx
after several days using it.
Hmmm
i found it quite intersesting
By default
it generate's everything(table,storeproc) that u click drag to the dbml
including store procedure(will be come a method in our vs)..
Hmmm.. i'm trying to bind ienumerable to infragistic grid, and it's a mess...
some table display valid some hang out. guess the datatable is the solution for binding or Customized through ultra data source
u can combine with extension or, just add your additional method to your object.
by default linq is optimistic concurrency.
meaning that if on multi user environment,when a user trying to update or delete a row which has been changed by other user it throws exception.
Using transaction in linq to sql :
http://blogs.msdn.com/wriju/archive/2007/08/06/linq-to-sql-using-transaction.aspx
Expression Math In String to Double
is there a time in your programming life when you meet such as changing
your math expression string x="3,14*(5^2)+(10^2)" like that or etc.
than what you need is an engine expression parser
May be below link can help and make life easier.
:)
http://www.c-sharpcorner.com/uploadfile/patricklundin/mathexpparser12062005062213am/mathexpparser.aspx
your math expression string x="3,14*(5^2)+(10^2)" like that or etc.
than what you need is an engine expression parser
May be below link can help and make life easier.
:)
http://www.c-sharpcorner.com/uploadfile/patricklundin/mathexpparser12062005062213am/mathexpparser.aspx
Selasa, 22 Januari 2008
The class name '?' is not a valid identifier for this language
This error can happen to the form designer
just close the visual studio 2008 and open it again
it will vanish
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=248764
just close the visual studio 2008 and open it again
it will vanish
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=248764
Senin, 14 Januari 2008
Codesmith.Data , Rules, Rules.validation And
if you are using plinq the latest one
and could not compile the codesmith.data Because
changedObjects.AddedEntities
changedObjects.ModifiedEntities
changedObjects.RemovedEntities
Change to
changedObjects.Inserts
changedObjects.Updates
changedObjects.Deletes
Respectively.
And it should run now
add reference to the misssing Codesmith.data it includes all to the rules etc.
and also notice to change the DBML generated by codesmith, change the Encoding to utf-8 instead of utd-16
HOpe this help who are needed
and could not compile the codesmith.data Because
changedObjects.AddedEntities
changedObjects.ModifiedEntities
changedObjects.RemovedEntities
Change to
changedObjects.Inserts
changedObjects.Updates
changedObjects.Deletes
Respectively.
And it should run now
add reference to the misssing Codesmith.data it includes all to the rules etc.
and also notice to change the DBML generated by codesmith, change the Encoding to utf-8 instead of utd-16
HOpe this help who are needed
Langganan:
Postingan (Atom)