Hello everyone,
I'm really a LINQ newbie. I got an unknown problem:
public static int save(TEntity obj)
{
var table = dbo.GetTable<TEntity>();
var mapping = dbo.Mapping.GetTable(typeof(TEntity));
var pkfield = mapping.RowType.DataMembers.Where(d => d.IsPrimaryKey).Take(1).SingleOrDefault();
if (Convert.ToInt32(obj.GetType().GetProperty(pkfield.Name).GetValue(obj, null)) == 0)
table.InsertOnSubmit(obj);
try
{
dbo.SubmitChanges();
}
catch (ChangeConflictException e)
{
dbo.SubmitChanges();
}
if (dbo.ChangeConflicts.Count == 0)
{
ClearCache(dbo);
return Convert.ToInt32(obj.GetType().GetProperty(pkfield.Name).GetValue(obj, null));
}
else
{
dbo.ChangeConflicts.ResolveAll(System.Data.Linq.RefreshMode.KeepCurrentValues);
return 0;
}
}
When using this method, there is only 1 field has been updated!! Here is my log:
UPDATE [dbo].[tbl_album]
SET [dt_m_date] = @p1
WHERE [i_album_id] = @p0
-- @p0: Input Int (Size = 0; Prec = 0; Scale = 0) [1]
-- @p1: Input BigInt (Size = 0; Prec = 0; Scale = 0) [1256485605]
-- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 3.5.30729.4918
Even I changed almost fields, my table has primary key already. But still problem.
Please help!